scidea-schools 1.0.0
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.
- data/MIT-LICENSE +7 -0
- data/README.md +1 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/backbone_apps/models/school.js +13 -0
- data/app/assets/javascripts/backbone_apps/school_selector.js +396 -0
- data/app/assets/stylesheets/scidea/admin/pages/schools/edit_user.css +57 -0
- data/app/assets/stylesheets/scidea/admin/pages/schools/user_migrate.css +3 -0
- data/app/assets/stylesheets/scidea/pages/schools/user_profile.css +53 -0
- data/app/controllers/admin/schools_controller.rb +125 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/schools_controller.rb +58 -0
- data/app/controllers/test/scidea_schools_qunit_tests_controller.rb +51 -0
- data/app/helpers/schools_helper.rb +22 -0
- data/app/models/school.rb +93 -0
- data/app/themes/global_sass/_mixins.scss +5 -0
- data/app/themes/scidea/sass/_config.scss +7 -0
- data/app/themes/scidea/sass/admin/pages/schools/edit_user.scss +14 -0
- data/app/themes/scidea/sass/admin/pages/schools/user_migrate.scss +21 -0
- data/app/themes/scidea/sass/components/_schools.scss +170 -0
- data/app/themes/scidea/sass/pages/schools/user_profile.scss +6 -0
- data/app/views/admin/schools/_form.html.erb +20 -0
- data/app/views/admin/schools/_school.html.erb +10 -0
- data/app/views/admin/schools/_search.html.erb +14 -0
- data/app/views/admin/schools/confirm_migration.html.erb +17 -0
- data/app/views/admin/schools/edit.html.erb +7 -0
- data/app/views/admin/schools/index.html.erb +60 -0
- data/app/views/admin/schools/new.html.erb +5 -0
- data/app/views/admin/schools/new_migration.html.erb +76 -0
- data/app/views/admin/schools/show.html.erb +46 -0
- data/app/views/admin/users/_profile_show_school.html.erb +4 -0
- data/app/views/admin/users/_school_edit.html.erb +5 -0
- data/app/views/layouts/application.html.erb +14 -0
- data/app/views/schools/_form.html.erb +19 -0
- data/app/views/schools/_profile_form.html.erb +43 -0
- data/app/views/schools/_script_form.html.erb +3 -0
- data/app/views/schools/_search.html.erb +6 -0
- data/app/views/users/_school_edit.html.erb +5 -0
- data/config/compass.rb +28 -0
- data/config/cucumber.yml +8 -0
- data/config/environment.rb +18 -0
- data/config/initializers/schools_assets.rb +6 -0
- data/config/locales/en.yml +8 -0
- data/config/requirejs.yml +2 -0
- data/config/routes.rb +25 -0
- data/db/seeds.rb +14 -0
- data/features/applying_for_seminars.feature +0 -0
- data/features/edit_seminar_application.feature +42 -0
- data/features/manage_users.feature +23 -0
- data/features/qunit/qunit.feature +7 -0
- data/features/schools/manage_schools.feature +87 -0
- data/features/schools/schools.feature +208 -0
- data/features/step_definitions/audience_steps.rb +10 -0
- data/features/step_definitions/authentication_steps.rb +34 -0
- data/features/step_definitions/custom_form_steps.rb +33 -0
- data/features/step_definitions/email_steps.rb +206 -0
- data/features/step_definitions/menu_steps.rb +4 -0
- data/features/step_definitions/misc_steps.rb +52 -0
- data/features/step_definitions/qunit_steps.rb +20 -0
- data/features/step_definitions/registration_steps.rb +17 -0
- data/features/step_definitions/school_steps.rb +35 -0
- data/features/step_definitions/seminar_application_steps.rb +16 -0
- data/features/step_definitions/seminar_steps.rb +5 -0
- data/features/step_definitions/steps.rb +0 -0
- data/features/step_definitions/user_steps.rb +16 -0
- data/features/step_definitions/web_steps.rb +211 -0
- data/features/support/env.rb +21 -0
- data/features/support/hooks.rb +16 -0
- data/features/support/paths.rb +39 -0
- data/features/support/seed_user_roles.rb +16 -0
- data/features/support/selectors.rb +66 -0
- data/lib/generators/scidea/schools/migrations_generator.rb +14 -0
- data/lib/generators/scidea/schools/removal_migrations_generator.rb +14 -0
- data/lib/generators/scidea/schools/templates/removal/scidea_schools_99_remove.rb +35 -0
- data/lib/generators/scidea/schools/templates/scidea_schools_01_install.rb +35 -0
- data/lib/scidea/schools/engine.rb +31 -0
- data/lib/scidea/schools/models/ability.rb +28 -0
- data/lib/scidea/schools/models/profile.rb +25 -0
- data/lib/scidea/schools/version.rb +5 -0
- data/lib/scidea/schools.rb +5 -0
- data/lib/scidea-schools.rb +1 -0
- data/lib/tasks/db/seed.rake +5 -0
- data/qunit/helpers/qunit.js +1598 -0
- data/qunit/html_fixtures/backbone_apps/_school_selector.html.erb +16 -0
- data/qunit/test_runner.html.erb +25 -0
- data/qunit/tests/backbone_apps/school_selector.js +50 -0
- data/spec/factories/schools.rb +10 -0
- data/spec/models/ability_spec.rb +27 -0
- data/spec/models/profile_spec.rb +38 -0
- data/spec/models/school_spec.rb +304 -0
- data/spec/routing/admin/admin_schools_routing_spec.rb +47 -0
- data/spec/routing/schools_routing_spec.rb +35 -0
- data/spec/spec_helper.rb +48 -0
- metadata +249 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
Feature: learners register and select a school with which they are associated
|
|
2
|
+
As a learner, I need to specify my school when I register for the site
|
|
3
|
+
|
|
4
|
+
Background:
|
|
5
|
+
Given there exists an audience "Educator"
|
|
6
|
+
Given I go to the home page
|
|
7
|
+
|
|
8
|
+
@javascript
|
|
9
|
+
Scenario: learner chooses educator from audience, but does not see the school fields because there are no schools in the system
|
|
10
|
+
Given I am on the registration page
|
|
11
|
+
And I fill in the core registration fields
|
|
12
|
+
And I select "Educator" from "Profession"
|
|
13
|
+
Then I should not see "zipcode before selecting a school"
|
|
14
|
+
|
|
15
|
+
@javascript
|
|
16
|
+
Scenario: learner chooses school during registration
|
|
17
|
+
Given there exist "4" schools in zipcode "12345"
|
|
18
|
+
Given there exists a school "My Favorite School" in zipcode "12345"
|
|
19
|
+
Given I am on the registration page
|
|
20
|
+
And I fill in the core registration fields
|
|
21
|
+
And I select "Educator" from "Profession"
|
|
22
|
+
And I fill in "school-select-zipcode" with "12345"
|
|
23
|
+
And I select "My Favorite School" from "School" after ".schools-found" loads
|
|
24
|
+
And I press "Register"
|
|
25
|
+
Then I should be logged in
|
|
26
|
+
And I follow "Logout"
|
|
27
|
+
|
|
28
|
+
@javascript
|
|
29
|
+
Scenario: user searches for school based on zipcode but yields no results
|
|
30
|
+
Given there exist "1" school in zipcode "12345"
|
|
31
|
+
Given I am on the registration page
|
|
32
|
+
And I fill in the core registration fields
|
|
33
|
+
And I select "Educator" from "Profession"
|
|
34
|
+
And I fill in "school-select-zipcode" with "00000"
|
|
35
|
+
Then I should see "No educational institutions found"
|
|
36
|
+
|
|
37
|
+
@javascript
|
|
38
|
+
Scenario: user searches for a school twice with two different zipcodes
|
|
39
|
+
Given there exists a school "My Favorite School" in zipcode "12345"
|
|
40
|
+
Given there exists a school "My Least Favorite School" in zipcode "00000"
|
|
41
|
+
Given I am on the registration page
|
|
42
|
+
And I fill in the core registration fields
|
|
43
|
+
And I select "Educator" from "Profession"
|
|
44
|
+
And I fill in "school-select-zipcode" with "12345"
|
|
45
|
+
And I select "My Favorite School" from "School" after ".schools-found" loads
|
|
46
|
+
And I fill in "school-select-zipcode" with "00000"
|
|
47
|
+
And "School" should not contain option "My Favorite School"
|
|
48
|
+
And I select "My Least Favorite School" from "School"
|
|
49
|
+
|
|
50
|
+
@javascript
|
|
51
|
+
Scenario: learner fails to choose school during registration and fails validation
|
|
52
|
+
Given there exists a school "My Favorite School"
|
|
53
|
+
Given I am on the registration page
|
|
54
|
+
And I fill in the core registration fields
|
|
55
|
+
And I select "Educator" from "Profession"
|
|
56
|
+
And I fill in "school-select-zipcode" with "12345"
|
|
57
|
+
And I press "Register"
|
|
58
|
+
Then I should see "Educational institution required"
|
|
59
|
+
|
|
60
|
+
@javascript
|
|
61
|
+
Scenario: learner adds a new school during registration and sees that school automatically assigned
|
|
62
|
+
Given there exist "2" schools in zipcode "12345"
|
|
63
|
+
Given I am on the registration page
|
|
64
|
+
And I fill in the core registration fields
|
|
65
|
+
And I select "Educator" from "Profession"
|
|
66
|
+
And I fill in "school-select-zipcode" with "12345"
|
|
67
|
+
And I follow "Add a new one." after ".schools-found, .schools-not-found" loads
|
|
68
|
+
And I fill in "Name" with "My Favorite School" within "#new-school-form"
|
|
69
|
+
And I fill in "Address" with "400 Preston" within "#new-school-form"
|
|
70
|
+
And I fill in "Address 2" with "Ste 300" within "#new-school-form"
|
|
71
|
+
And I fill in "City" with "Cville" within "#new-school-form"
|
|
72
|
+
And I select "Virginia" from "State" within "#new-school-form"
|
|
73
|
+
And I fill in "Zipcode" with "22902" within "#new-school-form"
|
|
74
|
+
And I fill in "Phone" with "9876543210" within "#new-school-form"
|
|
75
|
+
And I press "Add Institution"
|
|
76
|
+
Then "My Favorite School" should be selected for "school-id"
|
|
77
|
+
And I press "Register"
|
|
78
|
+
And I follow "Edit My Profile"
|
|
79
|
+
Then "My Favorite School" should be selected for "school-id"
|
|
80
|
+
|
|
81
|
+
@javascript
|
|
82
|
+
Scenario: learner adds a school with a zipcode starting with 0
|
|
83
|
+
Given there exist "1" schools in zipcode "01234"
|
|
84
|
+
Given I am on the registration page
|
|
85
|
+
And I fill in the core registration fields
|
|
86
|
+
And I select "Educator" from "Profession"
|
|
87
|
+
And I fill in "school-select-zipcode" with "01234"
|
|
88
|
+
And I follow "Add a new one." after ".schools-found, .schools-not-found" loads
|
|
89
|
+
And I fill in "Name" with "My Favorite School" within "#new-school-form"
|
|
90
|
+
And I fill in "Address" with "400 Preston" within "#new-school-form"
|
|
91
|
+
And I fill in "Address 2" with "Ste 300" within "#new-school-form"
|
|
92
|
+
And I fill in "City" with "Cville" within "#new-school-form"
|
|
93
|
+
And I select "Virginia" from "State" within "#new-school-form"
|
|
94
|
+
And I fill in "Zipcode" with "01234" within "#new-school-form"
|
|
95
|
+
And I fill in "Phone" with "9876543210" within "#new-school-form"
|
|
96
|
+
And I press "Add Institution"
|
|
97
|
+
Then "My Favorite School" should be selected for "school-id"
|
|
98
|
+
|
|
99
|
+
@javascript
|
|
100
|
+
Scenario: learner fails to add new school during registration because of validation issues
|
|
101
|
+
Given there exist "2" schools in zipcode "12345"
|
|
102
|
+
Given I am on the registration page
|
|
103
|
+
And I fill in the core registration fields
|
|
104
|
+
And I select "Educator" from "Profession"
|
|
105
|
+
And I fill in "school-select-zipcode" with "12345"
|
|
106
|
+
And I follow "Add a new one." after ".schools-found, .schools-not-found" loads
|
|
107
|
+
And I fill in "Name" with "My Favorite School" within "#new-school-form"
|
|
108
|
+
And I fill in "Address" with "400 Preston" within "#new-school-form"
|
|
109
|
+
And I select "Virginia" from "State" within "#new-school-form"
|
|
110
|
+
And I fill in "Phone" with "9876543210" within "#new-school-form"
|
|
111
|
+
And I press "Add Institution"
|
|
112
|
+
Then I should see "can't be blank"
|
|
113
|
+
And "My Favorite School" should not be selected for "school-id"
|
|
114
|
+
And I fill in "City" with "Cville" within "#new-school-form"
|
|
115
|
+
And I press "Add Institution"
|
|
116
|
+
Then "My Favorite School" should be selected for "school-id"
|
|
117
|
+
And I press "Register"
|
|
118
|
+
And I follow "Edit My Profile"
|
|
119
|
+
Then "My Favorite School" should be selected for "school-id"
|
|
120
|
+
|
|
121
|
+
@javascript
|
|
122
|
+
Scenario: learner adds a new school, but decides to edit it
|
|
123
|
+
Given there exists "1" school in zipcode "00000"
|
|
124
|
+
Given I am on the registration page
|
|
125
|
+
And I fill in the core registration fields
|
|
126
|
+
And I select "Educator" from "Profession"
|
|
127
|
+
And I fill in "school-select-zipcode" with "12345"
|
|
128
|
+
And I follow "add a new institution." after ".schools-not-found" loads
|
|
129
|
+
And I fill in "Name" with "My Favorite School" within "#new-school-form"
|
|
130
|
+
And I fill in "Address" with "400 Preston" within "#new-school-form"
|
|
131
|
+
And I fill in "City" with "Cville" within "#new-school-form"
|
|
132
|
+
And I select "Virginia" from "State" within "#new-school-form"
|
|
133
|
+
And I fill in "Zipcode" with "22902" within "#new-school-form"
|
|
134
|
+
And I fill in "Phone" with "9876543210" within "#new-school-form"
|
|
135
|
+
And I press "Add Institution"
|
|
136
|
+
Then "My Favorite School" should be selected for "school-id"
|
|
137
|
+
Then I follow "edit it." after "#edit-school" loads
|
|
138
|
+
And I fill in "Name" with "My Least Favorite School" within "#new-school-form"
|
|
139
|
+
And I press "Update Institution"
|
|
140
|
+
Then "My Least Favorite School" should be selected for "school-id"
|
|
141
|
+
And "school-id" should not contain option "My Favorite School"
|
|
142
|
+
And I press "Register"
|
|
143
|
+
And I follow "Edit My Profile"
|
|
144
|
+
Then "My Least Favorite School" should be selected for "school-id"
|
|
145
|
+
|
|
146
|
+
@javascript
|
|
147
|
+
Scenario: learner selects school but registration form fails to validate; school should be selected
|
|
148
|
+
Given there exists form "Profile" of type "Registration"
|
|
149
|
+
Given there exists a school "My Favorite School" in zipcode "12345"
|
|
150
|
+
Given there exists a "required" "text field" field "custom field" in "Profile"
|
|
151
|
+
Given I am on the registration page
|
|
152
|
+
And I fill in the core registration fields
|
|
153
|
+
And I select "Educator" from "Profession"
|
|
154
|
+
And I fill in "school-select-zipcode" with "12345"
|
|
155
|
+
And I select "My Favorite School" from "School" after ".schools-found" loads
|
|
156
|
+
And I press "Register"
|
|
157
|
+
And I fill in the core registration fields
|
|
158
|
+
And I fill in "custom field" with "blah"
|
|
159
|
+
Then "My Favorite School" should be selected for "School" after ".schools-found" loads
|
|
160
|
+
Then the "school-select-zipcode" field should contain "12345"
|
|
161
|
+
And I press "Register"
|
|
162
|
+
And I follow "Edit My Profile"
|
|
163
|
+
Then "My Favorite School" should be selected for "School" after ".schools-found" loads
|
|
164
|
+
|
|
165
|
+
@javascript
|
|
166
|
+
Scenario: when editing profile, user's school and zipcode should be selected and changes should persist
|
|
167
|
+
Given I login as a new learner
|
|
168
|
+
Given there exists a school "My New School" in zipcode "00000"
|
|
169
|
+
Given my school is "My Favorite School" in zipcode "12345"
|
|
170
|
+
Given I have "Educator" as my audience
|
|
171
|
+
And I follow "Edit My Profile"
|
|
172
|
+
Then the "school-select-zipcode" field should contain "12345"
|
|
173
|
+
And "My Favorite School" should be selected for "School" after ".schools-found" loads
|
|
174
|
+
Then I fill in "school-select-zipcode" with "00000"
|
|
175
|
+
And I select "My New School" from "School" after ".schools-found" loads
|
|
176
|
+
And I press "Update"
|
|
177
|
+
And I follow "Edit My Profile"
|
|
178
|
+
And "My New School" should be selected for "School" after ".schools-found" loads
|
|
179
|
+
|
|
180
|
+
@javascript
|
|
181
|
+
Scenario: admin edits user and goes to create a new school
|
|
182
|
+
Given there exists a menu element "Users" linking to "/admin/users" for menu "Admin Navigation: Secondary"
|
|
183
|
+
Given I login as a new "scitent admin"
|
|
184
|
+
Given there exists learner "aaa@test.local" named "bbb"
|
|
185
|
+
Given user "aaa@test.local" has school "Madison School"
|
|
186
|
+
When I follow "Users"
|
|
187
|
+
When I fill in "search" with "bbb"
|
|
188
|
+
And I press "Search"
|
|
189
|
+
When I follow "Edit"
|
|
190
|
+
And I follow "Add a new one." after ".schools-found, .schools-not-found" loads
|
|
191
|
+
Then I should be on the new admin school page
|
|
192
|
+
|
|
193
|
+
@javascript
|
|
194
|
+
Scenario: admin edits user and changes their school
|
|
195
|
+
Given there exists a menu element "Users" linking to "/admin/users" for menu "Admin Navigation: Secondary"
|
|
196
|
+
Given there exists a school "My New School" in zipcode "00000"
|
|
197
|
+
Given I login as a new "scitent admin"
|
|
198
|
+
Given there exists learner "aaa@test.local" named "bbb"
|
|
199
|
+
Given user "aaa@test.local" has school "Madison School"
|
|
200
|
+
When I follow "Users"
|
|
201
|
+
When I fill in "search" with "bbb"
|
|
202
|
+
And I press "Search"
|
|
203
|
+
When I follow "Edit"
|
|
204
|
+
And "Madison School" should be selected for "School" after ".schools-found" loads
|
|
205
|
+
And I fill in "school-select-zipcode" with "00000"
|
|
206
|
+
And I select "My New School" from "School" after ".schools-found" loads
|
|
207
|
+
And I press "Update"
|
|
208
|
+
Then I should see "My New School"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Given /^there exists a(?:n?) audience "([^"]*)"$/ do |name|
|
|
2
|
+
Factory :audience, :name => name
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Given /^I have "([^"]*)" as my audience$/ do |name|
|
|
6
|
+
audience = Audience.find_by_name(name) || Factory(:audience, :name => name)
|
|
7
|
+
me = User.first
|
|
8
|
+
me.profile.audience = audience
|
|
9
|
+
me.profile.save!
|
|
10
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Given /^I login as a new learner$/ do
|
|
2
|
+
step %{I login as a new "learner"}
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Given /^I login as a new "([^"]*)"$/ do |user_role|
|
|
6
|
+
password = 'password'
|
|
7
|
+
role_to_factory = { 'scitent admin' => :user_scitent_admin,
|
|
8
|
+
'tech support' => :user_tech_support,
|
|
9
|
+
'product admin' => :user_product_admin,
|
|
10
|
+
'course admin' => :user_course_admin,
|
|
11
|
+
'user admin' => :user_user_admin,
|
|
12
|
+
'learner' => :user_learner
|
|
13
|
+
}
|
|
14
|
+
user = Factory(role_to_factory[user_role], :password => password)
|
|
15
|
+
|
|
16
|
+
step %{I logout}
|
|
17
|
+
visit('/')
|
|
18
|
+
fill_in('user_email', :with => user.email)
|
|
19
|
+
fill_in('user_password', :with => password)
|
|
20
|
+
click_button('Sign in')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Then /^(?:|I )should be logged in$/ do
|
|
24
|
+
text = 'Edit My Profile'
|
|
25
|
+
if page.respond_to? :should
|
|
26
|
+
page.should have_content(text)
|
|
27
|
+
else
|
|
28
|
+
assert page.has_content?(text)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
Given /^I logout$/ do
|
|
33
|
+
visit('/users/sign_out')
|
|
34
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Given /^there exists form "([^"]*)"(?: of type "([^"]*)")?$/ do |form_name, form_type_name|
|
|
2
|
+
form_type_name ||= 'My Form Type'
|
|
3
|
+
Factory :form, :name => form_name, :form_type => Factory(:form_type, :name => form_type_name)
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
Given /^there exists an? "([^"]*)" "([^"]*)" field "([^"]*)" in "([^"]*)"$/ do |optional_or_required, field_type, field_name, form_name|
|
|
7
|
+
form = Form.find_by_name(form_name) || Factory( :form, :name => form_name )
|
|
8
|
+
form_section = form.form_sections.last || Factory( :form_section, :form => form )
|
|
9
|
+
|
|
10
|
+
required = optional_or_required == 'required'
|
|
11
|
+
field_sym = ('form_field_' + field_type.downcase.gsub(/ /, '_')).to_sym #converts field type string to factory symbol
|
|
12
|
+
Factory field_sym, :name => field_name, :form_section => form_section, :required => required
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Given /^there exists an? "([^"]*)" field "([^"]*)" in "([^"]*)" with options "([^"]*)"$/ do |field_type, field_name, form_name, option_list|
|
|
16
|
+
form = Form.find_by_name(form_name) || Factory( :form, :name => form_name )
|
|
17
|
+
form_section = form.form_sections.first || Factory( :form_section, :form => form )
|
|
18
|
+
|
|
19
|
+
field_sym = ('form_field_' + field_type.downcase.gsub(/ /, '_')).to_sym #converts field type string to factory symbol
|
|
20
|
+
field = Factory field_sym, :name => field_name, :form_section => form_section
|
|
21
|
+
|
|
22
|
+
option_list.split(',').each do |option|
|
|
23
|
+
Factory :form_field_option_value, :form_field => field, :value => option.strip
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Then /^the "([^"]*)" field should contain zipcode "([^"]*)"$/ do |label_text, zipcode|
|
|
28
|
+
label_for = find('label', :text => label_text)[:for]
|
|
29
|
+
zip1_id = label_for + '_us_zip1'
|
|
30
|
+
zip2_id = label_for + '_us_zip2'
|
|
31
|
+
find("##{zip1_id}").value.should == zipcode.split('-')[0]
|
|
32
|
+
find("##{zip2_id}").value.should == ( zipcode.split('-')[1] || '' )
|
|
33
|
+
end
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# Commonly used email steps
|
|
2
|
+
#
|
|
3
|
+
# To add your own steps make a custom_email_steps.rb
|
|
4
|
+
# The provided methods are:
|
|
5
|
+
#
|
|
6
|
+
# last_email_address
|
|
7
|
+
# reset_mailer
|
|
8
|
+
# open_last_email
|
|
9
|
+
# visit_in_email
|
|
10
|
+
# unread_emails_for
|
|
11
|
+
# mailbox_for
|
|
12
|
+
# current_email
|
|
13
|
+
# open_email
|
|
14
|
+
# read_emails_for
|
|
15
|
+
# find_email
|
|
16
|
+
#
|
|
17
|
+
# General form for email scenarios are:
|
|
18
|
+
# - clear the email queue (done automatically by email_spec)
|
|
19
|
+
# - execute steps that sends an email
|
|
20
|
+
# - check the user received an/no/[0-9] emails
|
|
21
|
+
# - open the email
|
|
22
|
+
# - inspect the email contents
|
|
23
|
+
# - interact with the email (e.g. click links)
|
|
24
|
+
#
|
|
25
|
+
# The Cucumber steps below are setup in this order.
|
|
26
|
+
|
|
27
|
+
module EmailHelpers
|
|
28
|
+
def current_email_address
|
|
29
|
+
# Replace with your a way to find your current email. e.g @current_user.email
|
|
30
|
+
# last_email_address will return the last email address used by email spec to find an email.
|
|
31
|
+
# Note that last_email_address will be reset after each Scenario.
|
|
32
|
+
last_email_address || "example@example.com"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
World(EmailHelpers)
|
|
37
|
+
|
|
38
|
+
#
|
|
39
|
+
# Reset the e-mail queue within a scenario.
|
|
40
|
+
# This is done automatically before each scenario.
|
|
41
|
+
#
|
|
42
|
+
|
|
43
|
+
Given /^(?:a clear email queue|no emails have been sent)$/ do
|
|
44
|
+
reset_mailer
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
#
|
|
48
|
+
# Check how many emails have been sent/received
|
|
49
|
+
#
|
|
50
|
+
|
|
51
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
|
|
52
|
+
unread_emails_for(address).size.should == parse_email_count(amount)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
|
|
56
|
+
mailbox_for(address).size.should == parse_email_count(amount)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
|
|
60
|
+
unread_emails_for(address).select { |m| m.subject =~ Regexp.new(Regexp.escape(subject)) }.size.should == parse_email_count(amount)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject \/([^"]*?)\/$/ do |address, amount, subject|
|
|
64
|
+
unread_emails_for(address).select { |m| m.subject =~ Regexp.new(subject) }.size.should == parse_email_count(amount)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
|
|
68
|
+
open_email(address, :with_text => expected_body)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
#
|
|
72
|
+
# Accessing emails
|
|
73
|
+
#
|
|
74
|
+
|
|
75
|
+
# Opens the most recently received email
|
|
76
|
+
When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
|
|
77
|
+
open_email(address)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
|
|
81
|
+
open_email(address, :with_subject => subject)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with subject \/([^"]*?)\/$/ do |address, subject|
|
|
85
|
+
open_email(address, :with_subject => Regexp.new(subject))
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
|
|
89
|
+
open_email(address, :with_text => text)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with text \/([^"]*?)\/$/ do |address, text|
|
|
93
|
+
open_email(address, :with_text => Regexp.new(text))
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
#
|
|
97
|
+
# Inspect the Email Contents
|
|
98
|
+
#
|
|
99
|
+
|
|
100
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
|
|
101
|
+
current_email.should have_subject(text)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
|
|
105
|
+
current_email.should have_subject(Regexp.new(text))
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
|
|
109
|
+
current_email.default_part_body.to_s.should include(text)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
|
|
113
|
+
current_email.default_part_body.to_s.should =~ Regexp.new(text)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
|
|
117
|
+
current_email.should be_delivered_from(text)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
Then /^(?:I|they) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
|
|
121
|
+
current_email.should have_header(name, text)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
Then /^(?:I|they) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
|
|
125
|
+
current_email.should have_header(name, Regexp.new(text))
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
Then /^I should see it is a multi\-part email$/ do
|
|
129
|
+
current_email.should be_multipart
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email html part body$/ do |text|
|
|
133
|
+
current_email.html_part.body.to_s.should include(text)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email text part body$/ do |text|
|
|
137
|
+
current_email.text_part.body.to_s.should include(text)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
#
|
|
141
|
+
# Inspect the Email Attachments
|
|
142
|
+
#
|
|
143
|
+
|
|
144
|
+
Then /^(?:I|they) should see (an|no|\d+) attachments? with the email$/ do |amount|
|
|
145
|
+
current_email_attachments.size.should == parse_email_count(amount)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
|
|
149
|
+
current_email_attachments.select { |a| a.filename == filename }.size.should == parse_email_count(amount)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
|
|
153
|
+
current_email_attachments[(index.to_i - 1)].filename.should == filename
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
|
|
157
|
+
current_email_attachments.select { |a| a.content_type.include?(content_type) }.size.should == parse_email_count(amount)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
|
|
161
|
+
current_email_attachments[(index.to_i - 1)].content_type.should include(content_type)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
Then /^all attachments should not be blank$/ do
|
|
165
|
+
current_email_attachments.each do |attachment|
|
|
166
|
+
attachment.read.size.should_not == 0
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
Then /^show me a list of email attachments$/ do
|
|
171
|
+
EmailSpec::EmailViewer::save_and_open_email_attachments_list(current_email)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
#
|
|
175
|
+
# Interact with Email Contents
|
|
176
|
+
#
|
|
177
|
+
|
|
178
|
+
When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
|
|
179
|
+
visit_in_email(link)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
When /^(?:I|they) click the first link in the email$/ do
|
|
183
|
+
click_first_link_in_email
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
#
|
|
187
|
+
# Debugging
|
|
188
|
+
# These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
|
|
189
|
+
# Patches accepted. ;)
|
|
190
|
+
#
|
|
191
|
+
|
|
192
|
+
Then /^save and open current email$/ do
|
|
193
|
+
EmailSpec::EmailViewer::save_and_open_email(current_email)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
Then /^save and open all text emails$/ do
|
|
197
|
+
EmailSpec::EmailViewer::save_and_open_all_text_emails
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
Then /^save and open all html emails$/ do
|
|
201
|
+
EmailSpec::EmailViewer::save_and_open_all_html_emails
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
Then /^save and open all raw emails$/ do
|
|
205
|
+
EmailSpec::EmailViewer::save_and_open_all_raw_emails
|
|
206
|
+
end
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
Given /^there exists a menu element "([^"]*)" linking to "([^"]*)" for menu "([^"]*)"$/ do |name, url, menu_name|
|
|
2
|
+
menu = Menu.find_by_name(menu_name) || Factory(:menu, :name => menu_name)
|
|
3
|
+
Factory(:menu_element_with_url, :display_name => name, :menu => menu, :url => url)
|
|
4
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Then /^"([^"]*)" should be selected for "([^"]*)"$/ do |value_or_text, field|
|
|
2
|
+
is_value = find_field(field).value =~ /#{value_or_text}/
|
|
3
|
+
is_text = field_labeled(field).find(:xpath, ".//option[text() = '#{value_or_text}']").selected?
|
|
4
|
+
|
|
5
|
+
(is_value || is_text).should be_true
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# @javascript only
|
|
9
|
+
Given /^I follow "([^"]*)" after "([^"]*)" loads$/ do |link, pending_content|
|
|
10
|
+
wait_until{ !page.find(:css, pending_content).nil? }
|
|
11
|
+
click_link(link)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# @javascript only
|
|
15
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)" after "([^"]*)" loads$/ do |value, field, pending_content|
|
|
16
|
+
wait_until{ !page.find(:css, pending_content).nil? }
|
|
17
|
+
select(value, :from => field)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @javascript only
|
|
21
|
+
Then /^"([^"]*)" should be selected for "([^"]*)" after "([^"]*)" loads$/ do |value, field, pending_content|
|
|
22
|
+
wait_until{ !page.find(:css, pending_content).nil? }
|
|
23
|
+
step "\"#{value}\" should be selected for \"#{field}\""
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
When /^I accept the (?:popup|confirmation dialog)$/ do
|
|
27
|
+
page.driver.browser.switch_to.alert.accept
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Then /^"([^"]*)" should not contain option "([^"]*)"$/ do |field, value|
|
|
32
|
+
field_labeled(field).has_no_xpath?(".//option[text() = '#{value}']").should be_true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
Then /^the page title should contain "([^"]*)"$/ do |text|
|
|
37
|
+
page.find('head title').text.include?(text).should be_true
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Then /^"([^"]*)" should not be selected for "([^"]*)"$/ do |value, field|
|
|
41
|
+
lambda{field_labeled(field).find(:xpath, ".//option[@selected][contains(string(), '#{value}')]") }.should raise_error
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
Then /^the (\d+)(?:st|nd|rd|th)(?: non-link|) item in the table should be "([^"]+)"$/ do |i, text|
|
|
45
|
+
tables = page.all("table")
|
|
46
|
+
tables.any?{ |table| table.all("tbody tr td")[i.to_i - 1].text.strip == text }.should be_true
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
Then /^the (\d+)(?:st|nd|rd|th)(?: non-link|) item in the table should start with "([^"]+)"$/ do |i, text|
|
|
50
|
+
tables = page.all("table")
|
|
51
|
+
tables.any?{ |table| table.all("tbody tr td")[i.to_i - 1].text.strip =~ /^#{text}/ }.should be_true
|
|
52
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
def qunit_results
|
|
2
|
+
result_str = "QUnit Results:\n\t" +
|
|
3
|
+
page.find("#qunit-testresult").text.split("\n").join("\n\t")
|
|
4
|
+
|
|
5
|
+
page.all(:xpath, "//ol[@id='qunit-tests']/li[@class='fail']").each do |element|
|
|
6
|
+
result_str += "\n\t" + element.find("strong").text
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
result_str + "\n"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Then /I should see no qunit failures$/ do
|
|
13
|
+
page.should have_css('#qunit-testresult')
|
|
14
|
+
page.should_not have_css('li.fail'), qunit_results
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Given /^I run the qunit tests$/ do
|
|
19
|
+
visit("/test/scidea_schools_qunit_tests")
|
|
20
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Given /^I complete the registration form$/ do
|
|
2
|
+
step %{I follow "Sign up"}
|
|
3
|
+
step %{I fill in the core registration fields}
|
|
4
|
+
step %{I press "Register"}
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
Given /^I fill in the core registration fields$/ do
|
|
8
|
+
step %{I fill in "user_email" with "learner01@test.local"}
|
|
9
|
+
step %{I fill in "user_password" with "password"}
|
|
10
|
+
step %{I fill in "user_password_confirmation" with "password"}
|
|
11
|
+
step %{I fill in "user_profile_attributes_first_name" with "Test"}
|
|
12
|
+
step %{I fill in "user_profile_attributes_last_name" with "Learner"}
|
|
13
|
+
step %{I select "Ms." from "user_profile_attributes_salutation"}
|
|
14
|
+
step %{I select "1980" from "user_profile_attributes_birthdate_1i"}
|
|
15
|
+
step %{I select "January" from "user_profile_attributes_birthdate_2i"}
|
|
16
|
+
step %{I select "1" from "user_profile_attributes_birthdate_3i"}
|
|
17
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Given /^there exist(?:s?) "([^"]*)" school(?:s?)(?: in zipcode "([^"]*)")?$/ do |schools_count, zipcode|
|
|
2
|
+
schools_count.to_i.times { zipcode.nil? ? Factory(:school) : Factory(:school, :zipcode => zipcode) }
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Given /^there exists an unapproved school "([^"]*)"$/ do |school_name|
|
|
6
|
+
Factory :school, :name => school_name, :approved => false
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Given /^there exists a school "([^"]*)"(?: in "([^"]*)")?$/ do |school_name, city_state|
|
|
10
|
+
if city_state
|
|
11
|
+
Factory :school, :name => school_name, :city => city_state.split(',')[0], :state => city_state.split(',')[1]
|
|
12
|
+
else
|
|
13
|
+
Factory :school, :name => school_name
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Given /^there exists a school "([^"]*)" in zipcode "([^"]*)"$/ do |school_name, zipcode|
|
|
18
|
+
if zipcode
|
|
19
|
+
Factory :school, :name => school_name, :zipcode => zipcode
|
|
20
|
+
else
|
|
21
|
+
Factory :school, :name => school_name
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Given /^there exists a learner associated with the school "([^"]*)"$/ do |school_name|
|
|
26
|
+
school = School.find_by_name(school_name) || Factory(:school, :name => school_name)
|
|
27
|
+
Factory :user_learner, :profile => Factory(:profile, :school => school)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Given /^my school is "([^"]*)" in zipcode "([^"]*)"$/ do |school_name, zipcode|
|
|
31
|
+
school = School.find_by_name(school_name) || Factory(:school, :name => school_name, :zipcode => zipcode)
|
|
32
|
+
me = User.first
|
|
33
|
+
me.profile.school = school
|
|
34
|
+
me.profile.save!
|
|
35
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Given /^there exists a seminar application for seminar "([^"]*)" and user "([^"]*)" named "([^"]*)"$/ do |seminar_name, user_email, user_name|
|
|
2
|
+
seminar = Seminar.find_by_name(seminar_name) || Factory(:seminar, :name => seminar_name)
|
|
3
|
+
user = User.find_by_email(user_email) || Factory(:user, :email => user_email, :profile => Factory(:profile, :last_name => user_name, :first_name => user_name))
|
|
4
|
+
seminar_application = Factory(:seminar_application, :seminar => seminar, :user => user)
|
|
5
|
+
seminar_application.set_submitted
|
|
6
|
+
seminar_application.save!
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Given /^field "([^"]*)" in seminar application form "([^"]*)" for user "([^"]*)" is set to "([^"]*)"$/ do |field, form, email, value|
|
|
10
|
+
seminar_application = SeminarApplication.last
|
|
11
|
+
form_response = FormResponse.first || Factory(:form_response, :form => Form.find_by_name(form), :user => User.find_by_email(email))
|
|
12
|
+
seminar_application.form_response = form_response
|
|
13
|
+
seminar_application.save!
|
|
14
|
+
Factory(:form_response_value, :form_field => FormField.find_by_name(field), :value => value, :form_response => form_response)
|
|
15
|
+
end
|
|
16
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Given /^seminar "([^"]*)" has application form "([^"]*)"$/ do |seminar_name, application_form|
|
|
2
|
+
seminar = Seminar.find_by_name ( seminar_name ) || Factory(:seminar, :name => seminar_name)
|
|
3
|
+
seminar.application_form = Factory(:form_seminar_application, :name => application_form)
|
|
4
|
+
seminar.save!
|
|
5
|
+
end
|
|
File without changes
|