Module: Holidays

Included in:
CreateHolidayCalendar, HolidayCalendarInfo
Defined in:
lib/sambal-kuali/base_page_classes.rb

Instance Method Summary collapse

Instance Method Details

#add_all_day_holiday(type, date, inst = false) ⇒ Object



186
187
188
189
190
191
192
193
194
195
196
# File 'lib/sambal-kuali/base_page_classes.rb', line 186

def add_all_day_holiday(type, date, inst=false)
  wait_until { holiday_type.enabled? }
  holiday_type.select type
  holiday_start_date.set date
  all_day.set unless all_day.set?
  date_range.clear if date_range.set?
  loading.wait_while_present
  instruct(inst)
  add_button.click
  loading.wait_while_present
end

#add_date_range_holiday(type, start_date, end_date, inst = false) ⇒ Object



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/sambal-kuali/base_page_classes.rb', line 198

def add_date_range_holiday(type, start_date, end_date, inst=false)
  wait_until { holiday_type.enabled? }
  holiday_type.select type
  holiday_start_date.set start_date
  all_day.set unless all_day.set?
  date_range.set unless date_range.set?
  loading.wait_while_present
  begin
    wait_until { holiday_end_date.enabled? }
  rescue Selenium::WebDriver::Error::StaleElementReferenceError
    sleep 2
  end
  holiday_end_date.set end_date
  instruct(inst)
  add_button.click
  loading.wait_while_present
end

#add_partial_day_holiday(type, start_date, start_time, start_meridian, end_time, end_meridian, inst = false) ⇒ Object



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/sambal-kuali/base_page_classes.rb', line 216

def add_partial_day_holiday(type, start_date, start_time, start_meridian, end_time, end_meridian, inst=false)
  wait_until { holiday_type.enabled? }
  holiday_type.select type
  holiday_start_date.set start_date
  all_day.clear if all_day.set?
  date_range.clear if date_range.set?
  loading.wait_while_present
  begin
    wait_until { holiday_end_time.enabled? }
  rescue Selenium::WebDriver::Error::StaleElementReferenceError
    sleep 2
  end
  holiday_start_time.set start_time
  holiday_start_meridian.select start_meridian
  holiday_end_time.set end_time
  holiday_end_meridian.select end_meridian
  instruct(inst)
  add_button.click
  loading.wait_while_present
end

#add_partial_range_holiday(type, start_date, start_time, start_meridian, end_date, end_time, end_meridian, inst = false) ⇒ Object



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/sambal-kuali/base_page_classes.rb', line 237

def add_partial_range_holiday(type, start_date, start_time, start_meridian, end_date, end_time, end_meridian, inst=false)
  wait_until { holiday_type.enabled? }
  holiday_type.select type
  holiday_start_date.set start_date
  all_day.clear if all_day.set?
  date_range.set unless date_range.set?
  loading.wait_while_present
  begin
    wait_until { holiday_end_date.enabled? }
  rescue Selenium::WebDriver::Error::StaleElementReferenceError
    sleep 2
  end
  holiday_start_time.set start_time
  holiday_start_meridian.select start_meridian
  holiday_end_date.set end_date
  holiday_end_time.set end_time
  holiday_end_meridian.select end_meridian
  instruct(inst)
  add_button.click
  loading.wait_while_present
end

#delete_holiday(holiday_type) ⇒ Object



259
260
261
262
# File 'lib/sambal-kuali/base_page_classes.rb', line 259

def delete_holiday(holiday_type)
  target_row(holiday_type).button(text: "delete").click
  loading.wait_while_present
end

#edit_end_time(holiday_type, time, meridian) ⇒ Object



274
275
276
277
278
# File 'lib/sambal-kuali/base_page_classes.rb', line 274

def edit_end_time(holiday_type, time, meridian)
  target_row(holiday_type).checkbox(name: /dateRange/).set unless target_row(holiday_type).checkbox(name: /dateRange/).set?
  target_row(holiday_type).text_field(name: /endTime\d/).set time
  target_row(holiday_type).text_field(name: /endTimeAmPm/).set meridian
end

#edit_start_date(holiday_type, date) ⇒ Object



264
265
266
# File 'lib/sambal-kuali/base_page_classes.rb', line 264

def edit_start_date(holiday_type, date)
  target_row(holiday_type).text_field(name: /startDate/).set date
end

#edit_start_time(holiday_type, time, meridian) ⇒ Object



268
269
270
271
272
# File 'lib/sambal-kuali/base_page_classes.rb', line 268

def edit_start_time(holiday_type, time, meridian)
  target_row(holiday_type).checkbox(name: /allDay/).clear if target_row(holiday_type).checkbox(name: /allDay/).set?
  target_row(holiday_type).text_field(name: /startTime\d/).set time
  target_row(holiday_type).text_field(name: /startTimeAmPm/).set meridian
end

#select_random_holidayObject

Returns a random item from the list of holidays



305
306
307
308
309
310
311
312
# File 'lib/sambal-kuali/base_page_classes.rb', line 305

def select_random_holiday
  holidays = []
  wait_until { holiday_type.enabled? }
  sleep 5
  holiday_type.options.each { |opt| holidays << opt.text }
  holidays.delete_if { |item| item == "Select holiday type" }
  holidays[rand(holidays.length)]
end

#toggle_all_day(holiday_type) ⇒ Object



280
281
282
283
284
285
286
# File 'lib/sambal-kuali/base_page_classes.rb', line 280

def toggle_all_day(holiday_type)
  if target_row(holiday_type).checkbox(name: /allDay/).set?
    target_row(holiday_type).checkbox(name: /allDay/).clear
  else
    target_row(holiday_type).checkbox(name: /allDay/).set
  end
end

#toggle_instructional(holiday_type) ⇒ Object



296
297
298
299
300
301
302
# File 'lib/sambal-kuali/base_page_classes.rb', line 296

def toggle_instructional(holiday_type)
  if target_row(holiday_type).checkbox(name: /instructional/).set?
    target_row(holiday_type).checkbox(name: /instructional/).clear
  else
    target_row(holiday_type).checkbox(name: /instructional/).set
  end
end

#toggle_range(holiday_type) ⇒ Object



288
289
290
291
292
293
294
# File 'lib/sambal-kuali/base_page_classes.rb', line 288

def toggle_range(holiday_type)
  if target_row(holiday_type).checkbox(name: /dateRange/).set?
    target_row(holiday_type).checkbox(name: /dateRange/).clear
  else
    target_row(holiday_type).checkbox(name: /dateRange/).set
  end
end