Class: EventObject

Inherits:
Object
  • Object
show all
Includes:
PageHelper, Utilities, Workflows
Defined in:
lib/sakai-cle-test-api/data_objects/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Workflows

menu_link, #open_my_site_by_name

Methods included from Utilities

#current_hour, #current_month, #current_year, #get_filename, #in_15_minutes, #last_hour, #last_month, #last_year, #make, #make_date, #next_hour, #next_month, #next_year, #on_page, #random_alphanums, #random_alphanums_plus, #random_email, #random_high_ascii, #random_letters, #random_multiline, #random_nicelink, #random_string, #random_xss_string, #tomorrow, #yesterday

Methods included from PageHelper

#make, #on, #visit, #wait_until

Constructor Details

#initialize(browser, opts = {}) ⇒ EventObject

Returns a new instance of EventObject.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 11

def initialize(browser, opts={})
  @browser = browser

  defaults = {
      :title=>random_alphanums,
      :month=>in_15_minutes[:month_str],
      :day=>in_15_minutes[:day],
      :year=>in_15_minutes[:year],
      :start_hour=>in_15_minutes[:hour],
      :start_minute=>in_15_minutes[:minute],
      :start_meridian=>in_15_minutes[:meridian],
      :duration_hours=>nil,
      :duration_minutes=>nil,
      :end_hour=>nil,
      :end_minute=>nil,
      :end_meridian=>nil,
      :message=>random_multiline(400,20, :alpha),
      :site=>"placeholder"
  }
  options = defaults.merge(opts)

  @title=options[:title]
  @month=options[:month]
  @day=options[:day]
  @year=options[:year]
  @start_hour=options[:start_hour]
  @start_minute=options[:start_minute]
  @start_meridian=options[:start_meridian]
  @duration_hours=options[:duration_hours]
  @duration_minutes=options[:duration_minutes]
  @end_hour=options[:end_hour]
  @end_minute=options[:end_minute]
  @end_meridian=options[:end_meridian]
  @message=options[:message]
  @site=options[:site]

end

Instance Attribute Details

#dayObject

Returns the value of attribute day.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def day
  @day
end

#duration_hoursObject

Returns the value of attribute duration_hours.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def duration_hours
  @duration_hours
end

#duration_minutesObject

Returns the value of attribute duration_minutes.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def duration_minutes
  @duration_minutes
end

#end_hourObject

Returns the value of attribute end_hour.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def end_hour
  @end_hour
end

#end_meridianObject

Returns the value of attribute end_meridian.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def end_meridian
  @end_meridian
end

#end_minuteObject

Returns the value of attribute end_minute.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def end_minute
  @end_minute
end

Returns the value of attribute link.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def link
  @link
end

#messageObject

Returns the value of attribute message.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def message
  @message
end

#monthObject

Returns the value of attribute month.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def month
  @month
end

#siteObject

Returns the value of attribute site.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def site
  @site
end

#start_hourObject

Returns the value of attribute start_hour.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def start_hour
  @start_hour
end

#start_meridianObject

Returns the value of attribute start_meridian.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def start_meridian
  @start_meridian
end

#start_minuteObject

Returns the value of attribute start_minute.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def start_minute
  @start_minute
end

#titleObject

Returns the value of attribute title.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def title
  @title
end

#yearObject

Returns the value of attribute year.



7
8
9
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 7

def year
  @year
end

Instance Method Details

#createObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/sakai-cle-test-api/data_objects/event.rb', line 49

def create
  open_my_site_by_name @site unless @browser.title=~/#{@site}/
  calendar unless @browser.title=~/Calendar$/
  on Calendar do |cal|
    cal.add
  end
  on AddEditEvent do |add_event|
    add_event.message.set @message
    add_event.title.set @title
    add_event.month.select @month
    add_event.day.select @day
    add_event.year.select @year
    add_event.start_hour.select @start_hour
    add_event.start_minute.select @start_minute
    add_event.start_meridian.select @start_meridian
    if @end_hour == nil && @duration_hours == nil
      @duration_hours = add_event.hours.value
      @duration_minutes = add_event.minutes.value
      @end_hour = add_event.end_hour.value
      @end_minute = add_event.end_minute.value
      @end_meridian = add_event.end_meridian.value
    elsif @end_hour == nil
      add_event.hours.select @duration_hours
      add_event.minutes.select @duration_minutes
      @end_hour = add_event.end_hour.value
      @end_minute = add_event.end_minute.value
      @end_meridian = add_event.end_meridian.value
    elsif @duration_hours == nil

    else

    end

    add_event.save_event
  end
  on Calendar do |cal|
    @link = cal.event_href @title
  end
end