Class: HolidayCalendar

Inherits:
Object
  • Object
show all
Includes:
DataFactory, DateFactory, Foundry, StringFactory, Workflows
Defined in:
lib/sambal-kuali/data_objects/holiday_calendar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Workflows

#go_to_academic_calendar, #go_to_calendar_search, #go_to_create_course_offerings, #go_to_create_population, #go_to_display_schedule_of_classes, #go_to_holiday_calendar, #go_to_manage_course_offerings, #go_to_manage_population, #go_to_perform_rollover, #go_to_rollover_details, #log_in, #logged_in_user

Constructor Details

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

Returns a new instance of HolidayCalendar.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sambal-kuali/data_objects/holiday_calendar.rb', line 11

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

  defaults = {
      :name=>random_alphanums.strip,
      :start_date=>"09/01/#{next_year[:year]}",
      :end_date=>"06/25/#{next_year[:year] + 1}",
      :organization=>"Registrar's Office",
      :holiday_types=>[
          {:type=>"random", :start_date=>"02/01/#{next_year[:year] + 1}", :all_day=>true, :date_range=>false, :instructional=>false},
          {:type=>"random", :start_date=>"03/02/#{next_year[:year] + 1}", :end_date=>"03/04/#{next_year[:year] + 1}", :all_day=>true, :date_range=>true, :instructional=>false},
          {:type=>"random", :start_date=>"04/05/#{next_year[:year] + 1}", :start_time=>"03:00", :start_meridian=>"pm", :end_time=>"07:44", :end_meridian=>"pm", :all_day=>false, :date_range=>false, :instructional=>false},
          {:type=>"random", :start_date=>"05/11/#{next_year[:year] + 1}", :start_time=>"02:22", :start_meridian=>"am", :end_date=>"05/22/#{next_year[:year] + 1}", :end_time=>"07:44", :end_meridian=>"pm", :all_day=>false, :date_range=>true, :instructional=>false}
      ]
  }
  options = defaults.merge(opts)
  set_options(options)
end

Instance Attribute Details

#end_dateObject

Returns the value of attribute end_date.



9
10
11
# File 'lib/sambal-kuali/data_objects/holiday_calendar.rb', line 9

def end_date
  @end_date
end

#holiday_typesObject

Returns the value of attribute holiday_types.



9
10
11
# File 'lib/sambal-kuali/data_objects/holiday_calendar.rb', line 9

def holiday_types
  @holiday_types
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/sambal-kuali/data_objects/holiday_calendar.rb', line 9

def name
  @name
end

#organizationObject

Returns the value of attribute organization.



9
10
11
# File 'lib/sambal-kuali/data_objects/holiday_calendar.rb', line 9

def organization
  @organization
end

#start_dateObject

Returns the value of attribute start_date.



9
10
11
# File 'lib/sambal-kuali/data_objects/holiday_calendar.rb', line 9

def start_date
  @start_date
end

Instance Method Details

#copy_from(name) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/sambal-kuali/data_objects/holiday_calendar.rb', line 68

def copy_from(name)
  go_to_holiday_calendar
  if right_source? name
    on CopyHolidayCalendar do |page|
      page.name.set @name
      page.start_date.set @start_date
      page.end_date.set @end_date
    end
  else
    on CopyHolidayCalendar do |page|
      page.choose_different_calendar
    end
    on CalendarSearch do |page|
      page.search_for "Holiday Calendar", name
      page.copy name
    end
    on EditAcademicCalendar do |page|
      page.academic_calendar_name.set @name
      page.organization.select @organization
      page.calendar_start_date.set @start_date
      page.calendar_end_date.set @end_date
    end
    on EditAcademicCalendar do |page|
      page.save
    end

    def search
      go_to_calendar_search
      on CalendarSearch do |page|
        page.search_for "Academic Calendar", @name
      end
    end

    def right_source?(name)
      on CreateAcadCalendar do |page|
        if page.source_name == name
          return true
        else
          return false
        end
      end
    end

    def make_official
      on EditAcademicCalendar do |page|
        page.make_official
      end
    end

  end
end

#createObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/sambal-kuali/data_objects/holiday_calendar.rb', line 30

def create
  go_to_holiday_calendar
  on CopyHolidayCalendar do |page|
    page.start_blank_calendar
  end
  on CreateHolidayCalendar do |page|
    page.name.set @name
    page.start_date.set @start_date
    page.end_date.set @end_date
    page.organization.select @organization
    @holiday_types.each do |holiday|
      if holiday[:type] == "random"
        page.select_random_holiday
        holiday[:type]=page.holiday_type.value
      else
        page.holiday_type.select holiday[:type]
      end
      page.holiday_start_date.set holiday[:start_date]
      if holiday[:date_range]
        page.date_range.set
        begin
          wait_until { holiday_end_date.enabled? }
        rescue Selenium::WebDriver::Error::StaleElementReferenceError
          sleep 2
        end
        page.holiday_end_date.set holiday[:end_date]
      else
        page.date_range.clear if page.date_range.set?
      end
      if holiday[:all_day]
        all_day.set unless all_day.set?
      else
        page.start_time
      end
    end
  end
end