kuali-sakai-common-lib 0.0.1 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. data/kuali-sakai-common-lib.gemspec +4 -5
  2. data/lib/kuali-sakai-common-lib.rb +3 -2
  3. data/lib/kuali-sakai-common-lib/add_files.rb +260 -0
  4. data/lib/kuali-sakai-common-lib/announcements.rb +301 -0
  5. data/lib/kuali-sakai-common-lib/assessments.rb +1183 -0
  6. data/lib/kuali-sakai-common-lib/assignments.rb +861 -0
  7. data/lib/kuali-sakai-common-lib/basic_lti.rb +13 -0
  8. data/lib/kuali-sakai-common-lib/blogs.rb +23 -0
  9. data/lib/kuali-sakai-common-lib/calendar.rb +466 -0
  10. data/lib/kuali-sakai-common-lib/calendar_summary.rb +0 -0
  11. data/lib/kuali-sakai-common-lib/chat_room.rb +0 -0
  12. data/lib/{core-ext.rb → kuali-sakai-common-lib/core-ext.rb} +0 -0
  13. data/lib/kuali-sakai-common-lib/drop_box.rb +0 -0
  14. data/lib/kuali-sakai-common-lib/email_archive.rb +28 -0
  15. data/lib/kuali-sakai-common-lib/forums.rb +326 -0
  16. data/lib/kuali-sakai-common-lib/gem_ext.rb +36 -0
  17. data/lib/kuali-sakai-common-lib/gradebook.rb +23 -0
  18. data/lib/kuali-sakai-common-lib/gradebook2.rb +24 -0
  19. data/lib/kuali-sakai-common-lib/messages.rb +639 -0
  20. data/lib/kuali-sakai-common-lib/news.rb +8 -0
  21. data/lib/kuali-sakai-common-lib/polls.rb +77 -0
  22. data/lib/kuali-sakai-common-lib/post_em.rb +0 -0
  23. data/lib/kuali-sakai-common-lib/profile.rb +46 -0
  24. data/lib/kuali-sakai-common-lib/profile2.rb +360 -0
  25. data/lib/kuali-sakai-common-lib/resources_roster.rb +0 -0
  26. data/lib/kuali-sakai-common-lib/rwiki.rb +0 -0
  27. data/lib/kuali-sakai-common-lib/sections.rb +237 -0
  28. data/lib/kuali-sakai-common-lib/single_user.rb +0 -0
  29. data/lib/kuali-sakai-common-lib/site_statistics.rb +0 -0
  30. data/lib/kuali-sakai-common-lib/syllabus.rb +182 -0
  31. data/lib/{utilities.rb → kuali-sakai-common-lib/utilities.rb} +13 -2
  32. metadata +51 -8
@@ -0,0 +1,13 @@
1
+ #================
2
+ # Basic LTI Pages
3
+ #================
4
+
5
+ #
6
+ module BasicLTIMethods
7
+ include PageObject
8
+ def self.page_elements(identifier)
9
+ in_frame(identifier) do |frame|
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,23 @@
1
+ #================
2
+ # Blog Pages - NOT "Blogger"
3
+ #================
4
+
5
+ #
6
+ module BlogsMethods
7
+ include PageObject
8
+ # Returns an array containing the list of Bloggers
9
+ # in the "All the blogs" table.
10
+ def blogger_list
11
+ bloggers = []
12
+ frm.table(:class=>"listHier lines").rows.each do |row|
13
+ bloggers << row[1].text
14
+ end
15
+ bloggers.delete_at(0)
16
+ return bloggers
17
+ end
18
+
19
+ def self.page_elements(identifier)
20
+ in_frame(identifier) do |frame|
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,466 @@
1
+ #================
2
+ # Calendar Pages
3
+ #================
4
+
5
+ module CalendarTools
6
+
7
+ #
8
+ def add_event
9
+ frm.link(:text=>"Add").click
10
+ frm.frame(:id, "description___Frame").td(:id, "xEditingArea").frame(:index=>0).wait_until_present
11
+ AddEditEvent.new(@browser)
12
+ end
13
+
14
+ #
15
+ def fields
16
+ frm.link(:text=>"Fields").click
17
+ AddEditFields.new(@browser)
18
+ end
19
+
20
+ #
21
+ def import
22
+ frm.link(:text=>"Import").click
23
+ ImportStepOne.new(@browser)
24
+ end
25
+
26
+ end
27
+
28
+ module CalendarMethods
29
+
30
+ # Selects the specified item in the View select list,
31
+ # then reinstantiates the Class.
32
+ def select_view(item)
33
+ frm.select(:id=>"view").select(item)
34
+ Calendar.new(@browser)
35
+ end
36
+
37
+ # Selects the specified item in the View select list.
38
+ # This is the same method as the select_view method, except
39
+ # that it does not reinstantiate the class. Use this if you're
40
+ # not concerned about throwing obsolete element errors when
41
+ # the page updates.
42
+ def view=(item)
43
+ frm.select(:id=>"view").select(item)
44
+ end
45
+
46
+ # Selects the specified item in the Show select list.
47
+ def show=(item)
48
+ frm.select(:id=>"timeFilterOption").select(item)
49
+ end
50
+
51
+ # Returns the text of the Calendar's header.
52
+ def header
53
+ frm.div(:class=>"portletBody").h3.text
54
+ end
55
+
56
+ # This is the alert box object. If you want to
57
+ # get the text contents of the alert box, use
58
+ # alert_box.text. That will get you a string object
59
+ # that is the text contents.
60
+ def alert_box
61
+ frm.div(:class=>"alertMessage")
62
+ end
63
+
64
+ # Clicks the link to the specified event, then
65
+ # instantiates the EventDetail class.
66
+ def open_event(title)
67
+ truncated = title[0..5]
68
+ frm.link(:text=>/#{Regexp.escape(truncated)}/).click
69
+ EventDetail.new(@browser)
70
+ end
71
+
72
+ # Returns the href value of the target link
73
+ # use for validation when you are testing whether the link
74
+ # will appear again on another screen, since often times
75
+ # validation by title text alone will not work.
76
+ def event_href(title)
77
+ truncated = title[0..5]
78
+ return frm.link(:text=>/#{Regexp.escape(truncated)}/).href
79
+ end
80
+
81
+ def show_events=(item)
82
+ frm.select(:id=>"timeFilterOption").select(item)
83
+ end
84
+
85
+ # Selects the specified value in the start month select list.
86
+ def start_month=(item)
87
+ frm.select(:id=>"customStartMonth").select(item)
88
+ end
89
+
90
+ # Selects the specified value in the start day select list.
91
+ def start_day=(item)
92
+ frm.select(:id=>"customStartDay").select(item)
93
+ end
94
+
95
+ # Selects the specified value in the start year select list.
96
+ def start_year=(item)
97
+ frm.select(:id=>"customStartYear").select(item)
98
+ end
99
+
100
+ # Selects the specified value in the end month select list.
101
+ def end_month=(item)
102
+ frm.select(:id=>"customEndMonth").select(item)
103
+ end
104
+
105
+ # Selects the specified value in the End Day select list.
106
+ def end_day=(item)
107
+ frm.select(:id=>"customEndDay").select(item)
108
+ end
109
+
110
+ # Selects the specified value in the End Year select list.
111
+ def end_year=(item)
112
+ frm.select(:id=>"customEndYear").select(item)
113
+ end
114
+
115
+ # Clicks the Filter Events button, then re-instantiates
116
+ # the Calendar class to avoid the possibility of an
117
+ # ObsoleteElement error.
118
+ def filter_events
119
+ frm.button(:name=>"eventSubmit_doCustomdate").click
120
+ Calendar.new(@browser)
121
+ end
122
+
123
+ # Clicks the Go to Today button, then reinstantiates
124
+ # the Calendar class.
125
+ def go_to_today
126
+ frm.button(:value=>"Go to Today").click
127
+ Calendar.new(@browser)
128
+ end
129
+
130
+ # Returns an array of the titles of the displayed events.
131
+ def event_list
132
+ events_list
133
+ end
134
+
135
+ # Returns an array for the listed events.
136
+ # This array contains more than simply strings of the event titles, because
137
+ # often the titles are truncated to fit on the screen. In addition, getting the "title"
138
+ # tag of the link is often problematic because titles can contain double-quotes, which
139
+ # will mess up the HTML of the anchor tag (there is probably an XSS vulnerability to
140
+ # exploit, there. This should be extensively tested.).
141
+ #
142
+ # Because of these issues, the array contains the title tag, the anchor text, and
143
+ # the entire href string for every event listed on the page. Having all three items
144
+ # available should ensure that verification steps don't give false results--especially
145
+ # when you are doing a negative test (checking that an event is NOT present).
146
+ def events_list
147
+ list = []
148
+ if frm.table(:class=>"calendar").exist?
149
+ events_table = frm.table(:class=>"calendar")
150
+ else
151
+ events_table = frm.table(:class=>"listHier lines nolines")
152
+ end
153
+ events_table.links.each do |link|
154
+ list << link.title
155
+ list << link.text
156
+ list << link.href
157
+ list << link.html[/(?<="location=").+doDescription/]
158
+ end
159
+ list.compact!
160
+ list.uniq!
161
+ return list
162
+ end
163
+
164
+ # Clicks the "Previous X" button, where X might be Day, Week, or Month,
165
+ # then reinstantiates the Calendar class to ensure against any obsolete element
166
+ # errors.
167
+ def previous
168
+ frm.button(:name=>"eventSubmit_doPrev").click
169
+ Calendar.new(@browser)
170
+ end
171
+
172
+ # Clicks the "Next X" button, where X might be Day, Week, or Month,
173
+ # then reinstantiates the Calendar class to ensure against any obsolete element
174
+ # errors.
175
+ def next
176
+ frm.button(:name=>"eventSubmit_doNext").click
177
+ Calendar.new(@browser)
178
+ end
179
+
180
+ # Clicks the "Today" button and reinstantiates the class.
181
+ def today
182
+ frm.button(:value=>"Today").click
183
+ Calendar.new(@browser)
184
+ end
185
+
186
+ def earlier
187
+ frm().link(:text=>"Earlier").click
188
+ Calendar.new(@browser)
189
+ end
190
+
191
+ def later
192
+ frm().link(:text=>"Later").click
193
+ Calendar.new(@browser)
194
+ end
195
+
196
+ # Clicks the "Set as Default View" button
197
+ def set_as_default_view
198
+ frm.link(:text=>"Set as Default View").click
199
+ end
200
+
201
+ end
202
+
203
+ module EventDetailMethods
204
+
205
+ # Clicks the Go to Today button, then instantiates
206
+ # the Calendar class.
207
+ def go_to_today
208
+ frm.button(:value=>"Go to Today").click
209
+ Calendar.new(@browser)
210
+ end
211
+
212
+ def back_to_calendar
213
+ frm.button(:value=>"Back to Calendar").click
214
+ Calendar.new(@browser)
215
+ end
216
+
217
+ def last_event
218
+ frm().button(:value=>"< Last Event").click
219
+ EventDetail.new(@browser)
220
+ end
221
+
222
+ def next_event
223
+ frm().button(:value=>"Next Event >").click
224
+ EventDetail.new(@browser)
225
+ end
226
+
227
+ def event_title
228
+ frm.div(:class=>"portletBody").h3.text
229
+ end
230
+
231
+ def edit
232
+ frm.button(:value=>"Edit").click
233
+ AddEditEvent.new(@browser)
234
+ end
235
+
236
+ def remove_event
237
+ frm.button(:value=>"Remove event").click
238
+ DeleteConfirm.new(@browser)
239
+ end
240
+
241
+ # Returns a hash object containing the contents of the event details
242
+ # table on the page, with each of the header column items as a Key
243
+ # and the associated data column as the corresponding Value.
244
+ def details
245
+ details = {}
246
+ frm.table(:class=>"itemSummary").rows.each do |row|
247
+ details.store(row.th.text, row.td.text)
248
+ end
249
+ return details
250
+ end
251
+
252
+ end
253
+
254
+ module AddEditEventMethods
255
+ include PageObject
256
+ #
257
+ def save_event
258
+ frm.button(:value=>"Save Event").click
259
+ Calendar.new(@browser)
260
+ end
261
+ #
262
+ def message=(text)
263
+ frm.frame(:id, "description___Frame").td(:id, "xEditingArea").frame(:index=>0).send_keys(text)
264
+ end
265
+
266
+ # The FCKEditor object. Use this method to set up a "wait_until_present"
267
+ # step, since sometimes it takes a long time for this object to load.
268
+ def message_editor
269
+ frm.frame(:id, "description___Frame").td(:id, "xEditingArea").frame(:index=>0)
270
+ end
271
+
272
+ def frequency
273
+ frm.button(:name=>"eventSubmit_doEditfrequency").click
274
+ EventFrequency.new(@browser)
275
+ end
276
+
277
+ def add_attachments
278
+ frm.button(:value=>"Add Attachments").click
279
+ EventAttach.new(@browser)
280
+ end
281
+
282
+ def add_remove_attachments
283
+ frm.button(:value=>"Add/remove attachments").click
284
+ EventAttach.new(@browser)
285
+ end
286
+
287
+ # Returns true if the page has a link with the
288
+ # specified file name. Use for test case asserts.
289
+ def attachment?(file_name)
290
+ frm.link(:text=>file_name).exist?
291
+ end
292
+
293
+ # Use this method to enter text into custom fields
294
+ # on the page. The "field" variable is the name of the
295
+ # field, while the "text" is the string you want to put into
296
+ # it.
297
+ def custom_field_text(field, text)
298
+ frm.text_field(:name=>field).set(text)
299
+ end
300
+
301
+ def self.page_elements(identifier)
302
+ in_frame(identifier) do |frame|
303
+ text_field(:title, :id=>"activitytitle", :frame=>frame)
304
+ select_list(:month, :id=>"month", :frame=>frame)
305
+ select_list(:day, :id=>"day", :frame=>frame)
306
+ select_list(:year, :id=>"yearSelect", :frame=>frame)
307
+ select_list(:start_hour, :id=>"startHour", :frame=>frame)
308
+ select_list(:start_minute, :id=>"startMinute", :frame=>frame)
309
+ select_list(:start_meridian, :id=>"startAmpm", :frame=>frame)
310
+ select_list(:hours, :id=>"duHour", :frame=>frame)
311
+ select_list(:minutes, :id=>"duMinute", :frame=>frame)
312
+ select_list(:end_hour, :id=>"endHour", :frame=>frame)
313
+ select_list(:end_minute, :id=>"endMinute", :frame=>frame)
314
+ select_list(:end_meridian, :id=>"endAmpm", :frame=>frame)
315
+ radio_button(:display_to_site, :id=>"site", :frame=>frame)
316
+ select_list(:event_type, :id=>"eventType", :frame=>frame)
317
+ text_area(:location, :name=>"location", :frame=>frame)
318
+ end
319
+ end
320
+ end
321
+
322
+ # The page that appears when the Frequency button is clicked on the Add/Edit
323
+ # Event page.
324
+ module EventFrequencyMethods
325
+ include PageObject
326
+ def save_frequency
327
+ frm.button(:value=>"Save Frequency").click
328
+ AddEditEvent.new(@browser)
329
+ end
330
+
331
+ def cancel
332
+ frm.button(:value=>"Cancel").click
333
+ AddEditEvent.new(@browser)
334
+ end
335
+
336
+ def self.page_elements(identifier)
337
+ in_frame(identifier) do |frame|
338
+ select_list(:event_frequency, :id=>"frequencySelect", :frame=>frame)
339
+ select_list(:interval, :id=>"interval", :frame=>frame)
340
+ select_list(:ends_after, :name=>"count", :frame=>frame)
341
+ select_list(:ends_month, :id=>"endMonth", :frame=>frame)
342
+ select_list(:ends_day, :id=>"endDay", :frame=>frame)
343
+ select_list(:ends_year, :id=>"endYear", :frame=>frame)
344
+ radio_button(:after, :id=>"count", :frame=>frame)
345
+ radio_button(:on, :id=>"till", :frame=>frame)
346
+ radio_button(:never, :id=>"never", :frame=>frame)
347
+ end
348
+ end
349
+ end
350
+
351
+ #
352
+ module AddEditFieldsMethods
353
+ include PageObject
354
+ # Clicks the Save Field Changes buton and instantiates
355
+ # The Calendar or EventDetail class--unless the Alert Message box appears,
356
+ # in which case it re-instantiates the class.
357
+ def save_field_changes
358
+ frm.button(:value=>"Save Field Changes").click
359
+ if frm.div(:class=>"alertMessage").exist?
360
+ AddEditFields.new(@browser)
361
+ elsif frm.button(:value=>"Back to Calendar").exist?
362
+ EventDetail.new(@browser)
363
+ else
364
+ Calendar.new(@browser)
365
+ end
366
+ end
367
+
368
+ # Returns a string of the contents of the Alert box.
369
+ def alert_box
370
+ frm.div(:class=>"alertMessage").text
371
+ end
372
+
373
+ def create_field
374
+ frm.button(:value=>"Create Field").click
375
+ AddEditFields.new(@browser)
376
+ end
377
+
378
+ # Checks the checkbox for the specified field
379
+ def check_remove(field_name)
380
+ frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(field_name)}/).checkbox.set
381
+ end
382
+
383
+ def self.page_elements(identifier)
384
+ in_frame(identifier) do |frame|
385
+ text_field(:field_name, :id=>"textfield", :frame=>frame)
386
+ end
387
+ end
388
+ end
389
+
390
+ #
391
+ module ImportStepOneMethods
392
+ include PageObject
393
+ def continue
394
+ frm.button(:value=>"Continue").click
395
+ ImportStepTwo.new(@browser)
396
+ end
397
+
398
+ def self.page_elements(identifier)
399
+ in_frame(identifier) do |frame|
400
+ radio_button(:microsoft_outlook, :id=>"importType_Outlook", :frame=>frame)
401
+ radio_button(:meeting_maker, :id=>"importType_MeetingMaker", :frame=>frame)
402
+ radio_button(:generic_calendar_import, :id=>"importType_Generic", :frame=>frame)
403
+ end
404
+ end
405
+ end
406
+
407
+ #
408
+ module ImportStepTwoMethods
409
+
410
+ def continue
411
+ frm.button(:value=>"Continue").click
412
+ ImportStepThree.new(@browser)
413
+ end
414
+
415
+ # Enters the specified filename in the file field.
416
+ #
417
+ # Note that the file path is an optional second parameter, if you do not want to
418
+ # include the full path in the filename.
419
+ def import_file(filename, filepath="")
420
+ frm.file_field(:name=>"importFile").set(filepath + filename)
421
+ end
422
+
423
+ end
424
+
425
+ # The page for reviewing activities and confirming them for import.
426
+ module ImportStepThreeMethods
427
+ include PageObject
428
+ def import_events
429
+ frm.button(:value=>"Import Events").click
430
+ Calendar.new(@browser)
431
+ end
432
+
433
+ # Returns an array containing the list of Activity names on the page.
434
+ def events
435
+ list = []
436
+ frm.table(:class=>/listHier lines/).rows.each do |row|
437
+ if row.label(:for=>/eventSelected/).exist?
438
+ list << row.label.text
439
+ end
440
+ end
441
+ names = []
442
+ list.uniq!
443
+ list.each do | item |
444
+ name = item[/(?<=\s).+(?=\s\s\()/]
445
+ names << name
446
+ end
447
+ return names
448
+ end
449
+
450
+ # Returns the date of the specified event
451
+ def event_date(event_name)
452
+ frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(event_name)}/)[0].text
453
+ end
454
+
455
+ # Unchecks the checkbox for the specified event
456
+ def uncheck_event(event_name)
457
+ frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(event_name)}/)
458
+ end
459
+
460
+ def self.page_elements(identifier)
461
+ in_frame(identifier) do |frame|
462
+ radio_button(:import_events_for_site, :id=>"site", :frame=>frame)
463
+ radio_button(:import_events_for_selected_groups, :id=>"groups", :frame=>frame)
464
+ end
465
+ end
466
+ end