Class: SiteObject

Inherits:
Object
  • Object
show all
Includes:
PageHelper, Utilities, Workflows
Defined in:
lib/sakai-cle-test-api/data_objects/site.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 = {}) ⇒ SiteObject

Returns a new instance of SiteObject.



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
# File 'lib/sakai-cle-test-api/data_objects/site.rb', line 11

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

  defaults = {
    :subject => random_alphanums(8),
    :course => random_alphanums(8),
    :section => random_alphanums(8),
    :authorizer => "admin",
    :web_content_title => random_alphanums(15),
    :web_content_source => "http://www.rsmart.com",
    :email=>random_nicelink(32),
    :joiner_role => "Student",
    :description => random_alphanums(30),
    :short_description => random_alphanums,
    :site_contact_name => random_alphanums(5)+" "+random_alphanums(8)
  }
  options = defaults.merge(opts)

  @subject=options[:subject]
  @course=options[:course]
  @section=options[:section]
  @authorizer=options[:authorizer]
  @web_content_source=options[:web_content_source]
  @email=options[:email]
  @joiner_role=options[:joiner_role]
  @web_content_title=options[:web_content_title]
  @description=options[:description]
  @short_description=options[:short_description]
  @site_contact_name=options[:site_contact_name]
  @site_contact_email=options[:site_contact_email]
end

Instance Attribute Details

#authorizerObject

Returns the value of attribute authorizer.



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

def authorizer
  @authorizer
end

#courseObject

Returns the value of attribute course.



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

def course
  @course
end

#creation_dateObject

Returns the value of attribute creation_date.



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

def creation_date
  @creation_date
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#joiner_roleObject

Returns the value of attribute joiner_role.



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

def joiner_role
  @joiner_role
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#sectionObject

Returns the value of attribute section.



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

def section
  @section
end

#short_descriptionObject

Returns the value of attribute short_description.



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

def short_description
  @short_description
end

#site_contact_emailObject

Returns the value of attribute site_contact_email.



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

def site_contact_email
  @site_contact_email
end

#site_contact_nameObject

Returns the value of attribute site_contact_name.



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

def site_contact_name
  @site_contact_name
end

#subjectObject

Returns the value of attribute subject.



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

def subject
  @subject
end

#termObject

Returns the value of attribute term.



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

def term
  @term
end

#web_content_sourceObject

Returns the value of attribute web_content_source.



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

def web_content_source
  @web_content_source
end

#web_content_titleObject

Returns the value of attribute web_content_title.



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

def web_content_title
  @web_content_title
end

Instance Method Details

#createObject



43
44
45
46
47
48
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
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
# File 'lib/sakai-cle-test-api/data_objects/site.rb', line 43

def create
  my_workspace unless @browser.title=~/My Workspace/
  site_setup unless @browser.title=~/Site Setup/
  on_page SiteSetup do |page|
    page.new
  end
  on SiteType do |page|
    # Select the Course Site radio button
    page.course_site.set
    # Store the selected term value for use later
    @term = page.academic_term.value

    page.continue
  end
  on CourseSectionInfo do |page|
    # Fill in those fields, storing the entered values for later verification steps
    page.subject.set @subject

    page.course.set @course

    page.section.set @section

    # Store site name for ease of coding and readability later
    @name = "#{@subject} #{@course} #{@section} #{@term}"
    # Add a valid instructor id
    page.authorizers_username.set @authorizer

    # Click continue button
    page.continue
  end
  on CourseSiteInfo do |page|
    page.short_description.set @short_description
    page.site_contact_name.set @site_contact_name
    page.site_contact_email.set @site_contact_email
    page.enter_source_text page.editor, @description

    # Click Continue
    page.continue
  end
  on EditSiteTools do |page|
    #Check All Tools
    page.all_tools.set
    page.continue
  end
  on AddMultipleTools do |add_tools|
    add_tools.site_email_address.set @email
    add_tools.web_content_title.set @web_content_title
    add_tools.web_content_source.set @web_content_source

    add_tools.continue
  end
  on SiteAccess do |access|
    access.allow.set
    access.joiner_role.select @joiner_role
    access.continue
  end
  on ConfirmSiteSetup do |review|
    review.request_site
  end

  # Create a string that will match the new Site's "creation date" string
  @creation_date = make_date(Time.now)

  on SiteSetup do |site_setup|
    site_setup.search(Regexp.escape(@subject))

    # Get the site id for storage
    @browser.frame(:class=>"portletMainIframe").link(:href=>/xsl-portal.site/, :index=>0).href =~ /(?<=\/site\/).+/
    @id = $~.to_s
  end
end

#create_and_reuse_site(site_name) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/sakai-cle-test-api/data_objects/site.rb', line 115

def create_and_reuse_site(site_name)
  my_workspace unless @browser.title=~/My Workspace/
  site_setup unless @browser.title=~/Site Setup/
  on_page SiteSetup do |page|
    page.new
  end
  on SiteType do |site_type|

    # Select the Course Site radio button

    site_type.course_site.set

    # Store the selected term value for use later
    @term = site_type.academic_term.value

    # Click continue
    site_type.continue
  end
  on CourseSectionInfo do |course_section|
    # Fill in those fields, storing the entered values for later verification steps
    course_section.subject.set @subject

    course_section.course.set @course

    course_section.section.set @section

    # Store site name for ease of coding and readability later
    @name = "#{@subject} #{@course} #{@section} #{@term}"

    # Add a valid instructor id
    course_section.authorizers_username.set @authorizer

    # Click continue button
    course_section.continue
  end
  on CourseSiteInfo do |course_site|
    course_site.enter_source_text course_site.editor, @description
    course_site.short_description.set @short_description
    # Click Continue
    course_site.continue
  end
  on EditSiteTools do |course_tools|
    #Check All Tools
    course_tools.all_tools.set
    course_tools.yes.set
    course_tools.import_sites.select site_name
    course_tools.continue
  end
  on_page ReUseMaterial do |page|
    page.announcements_checkbox.set
    page.calendar_checkbox.set
    page.discussion_forums_checkbox.set
    page.forums_checkbox.set
    page.chat_room_checkbox.set
    page.polls_checkbox.set
    page.syllabus_checkbox.set
    page.lessons_checkbox.set
    page.resources_checkbox.set
    page.assignments_checkbox.set
    page.tests_and_quizzes_checkbox.set
    page.gradebook_checkbox.set
    page.gradebook2_checkbox.set
    page.wiki_checkbox.set
    page.news_checkbox.set
    page.web_content_checkbox.set
    page.site_statistics_checkbox.set
    page.continue
  end
  on_page AddMultipleTools do |page|
    page.site_email_address.set @email
    page.web_content_title.set @web_content_title
    page.web_content_source.set @web_content_source
    page.continue
  end
  on_page SiteAccess do |page|
    page.allow.set
    page.joiner_role.select @joiner_role
    page.continue
  end
  on_page ConfirmSiteSetup do |page|
    page.request_site
  end
  # Create a string that will match the new Site's "creation date" string
  @creation_date = make_date(Time.now)
  on_page SiteSetup do |page|
    page.search(Regexp.escape(@subject))
  end
  # Get the site id for storage
  @browser.frame(:class=>"portletMainIframe").link(:href=>/xsl-portal.site/, :index=>0).href =~ /(?<=\/site\/).+/
  @id = $~.to_s

end