devise 3.2.0 → 3.3.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.
Potentially problematic release.
This version of devise might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.travis.yml +18 -3
- data/CHANGELOG.md +82 -9
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +7 -9
- data/Gemfile.lock +102 -96
- data/MIT-LICENSE +1 -1
- data/README.md +94 -42
- data/Rakefile +1 -1
- data/app/controllers/devise/confirmations_controller.rb +5 -3
- data/app/controllers/devise/omniauth_callbacks_controller.rb +2 -2
- data/app/controllers/devise/passwords_controller.rb +5 -3
- data/app/controllers/devise/registrations_controller.rb +26 -10
- data/app/controllers/devise/sessions_controller.rb +39 -14
- data/app/controllers/devise/unlocks_controller.rb +4 -2
- data/app/controllers/devise_controller.rb +6 -6
- data/app/helpers/devise_helper.rb +2 -2
- data/app/views/devise/confirmations/new.html.erb +2 -2
- data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
- data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
- data/app/views/devise/mailer/unlock_instructions.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +3 -3
- data/app/views/devise/passwords/new.html.erb +2 -2
- data/app/views/devise/registrations/edit.html.erb +6 -6
- data/app/views/devise/registrations/new.html.erb +5 -5
- data/app/views/devise/sessions/new.html.erb +5 -5
- data/app/views/devise/shared/_links.erb +1 -1
- data/app/views/devise/unlocks/new.html.erb +2 -2
- data/config/locales/en.yml +17 -16
- data/devise.gemspec +2 -2
- data/gemfiles/{Gemfile.rails-3.2.x → Gemfile.rails-3.2-stable} +8 -10
- data/gemfiles/Gemfile.rails-3.2-stable.lock +166 -0
- data/gemfiles/Gemfile.rails-4.0-stable +29 -0
- data/gemfiles/Gemfile.rails-4.0-stable.lock +162 -0
- data/gemfiles/Gemfile.rails-head +32 -0
- data/gemfiles/Gemfile.rails-head.lock +190 -0
- data/lib/devise/controllers/helpers.rb +84 -29
- data/lib/devise/controllers/rememberable.rb +3 -3
- data/lib/devise/controllers/scoped_views.rb +1 -1
- data/lib/devise/controllers/sign_in_out.rb +9 -10
- data/lib/devise/controllers/store_location.rb +56 -0
- data/lib/devise/controllers/url_helpers.rb +3 -1
- data/lib/devise/failure_app.rb +12 -10
- data/lib/devise/hooks/activatable.rb +5 -6
- data/lib/devise/hooks/csrf_cleaner.rb +3 -1
- data/lib/devise/hooks/lockable.rb +1 -1
- data/lib/devise/hooks/proxy.rb +2 -2
- data/lib/devise/hooks/rememberable.rb +2 -2
- data/lib/devise/hooks/timeoutable.rb +10 -3
- data/lib/devise/hooks/trackable.rb +1 -1
- data/lib/devise/mailers/helpers.rb +8 -8
- data/lib/devise/mapping.rb +4 -1
- data/lib/devise/models/authenticatable.rb +5 -5
- data/lib/devise/models/confirmable.rb +14 -14
- data/lib/devise/models/database_authenticatable.rb +18 -5
- data/lib/devise/models/lockable.rb +14 -11
- data/lib/devise/models/omniauthable.rb +1 -1
- data/lib/devise/models/recoverable.rb +23 -7
- data/lib/devise/models/rememberable.rb +6 -6
- data/lib/devise/models/timeoutable.rb +2 -2
- data/lib/devise/models/trackable.rb +5 -2
- data/lib/devise/models/validatable.rb +6 -6
- data/lib/devise/modules.rb +10 -10
- data/lib/devise/omniauth/url_helpers.rb +2 -2
- data/lib/devise/orm/active_record.rb +1 -1
- data/lib/devise/orm/mongoid.rb +1 -1
- data/lib/devise/rails/routes.rb +107 -78
- data/lib/devise/rails.rb +7 -1
- data/lib/devise/strategies/authenticatable.rb +11 -4
- data/lib/devise/strategies/base.rb +1 -1
- data/lib/devise/strategies/database_authenticatable.rb +7 -4
- data/lib/devise/test_helpers.rb +2 -2
- data/lib/devise/time_inflector.rb +2 -2
- data/lib/devise/version.rb +1 -1
- data/lib/devise.rb +15 -10
- data/lib/generators/active_record/devise_generator.rb +27 -10
- data/lib/generators/active_record/templates/migration.rb +4 -4
- data/lib/generators/active_record/templates/migration_existing.rb +4 -4
- data/lib/generators/devise/devise_generator.rb +5 -3
- data/lib/generators/devise/install_generator.rb +5 -0
- data/lib/generators/devise/views_generator.rb +31 -18
- data/lib/generators/mongoid/devise_generator.rb +20 -19
- data/lib/generators/templates/README +4 -4
- data/lib/generators/templates/devise.rb +20 -11
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
- data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
- data/lib/generators/templates/markerb/unlock_instructions.markerb +1 -1
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +2 -2
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +2 -2
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -6
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +2 -2
- data/script/cached-bundle +49 -0
- data/script/s3-put +71 -0
- data/test/controllers/custom_registrations_controller_test.rb +35 -0
- data/test/controllers/helpers_test.rb +89 -31
- data/test/controllers/internal_helpers_test.rb +11 -8
- data/test/controllers/passwords_controller_test.rb +1 -1
- data/test/controllers/sessions_controller_test.rb +29 -25
- data/test/controllers/url_helpers_test.rb +4 -4
- data/test/delegator_test.rb +1 -1
- data/test/devise_test.rb +21 -8
- data/test/failure_app_test.rb +61 -25
- data/test/generators/active_record_generator_test.rb +10 -4
- data/test/generators/devise_generator_test.rb +2 -2
- data/test/generators/mongoid_generator_test.rb +3 -3
- data/test/generators/views_generator_test.rb +30 -1
- data/test/helpers/devise_helper_test.rb +14 -13
- data/test/integration/authenticatable_test.rb +61 -45
- data/test/integration/confirmable_test.rb +95 -55
- data/test/integration/database_authenticatable_test.rb +16 -16
- data/test/integration/http_authenticatable_test.rb +12 -12
- data/test/integration/lockable_test.rb +43 -43
- data/test/integration/omniauthable_test.rb +3 -3
- data/test/integration/recoverable_test.rb +53 -53
- data/test/integration/registerable_test.rb +90 -80
- data/test/integration/rememberable_test.rb +15 -15
- data/test/integration/timeoutable_test.rb +27 -16
- data/test/integration/trackable_test.rb +4 -4
- data/test/mailers/confirmation_instructions_test.rb +7 -7
- data/test/mailers/reset_password_instructions_test.rb +6 -6
- data/test/mailers/unlock_instructions_test.rb +5 -5
- data/test/mapping_test.rb +3 -3
- data/test/models/authenticatable_test.rb +3 -3
- data/test/models/confirmable_test.rb +32 -32
- data/test/models/database_authenticatable_test.rb +32 -27
- data/test/models/lockable_test.rb +57 -33
- data/test/models/recoverable_test.rb +34 -22
- data/test/models/rememberable_test.rb +29 -14
- data/test/models/serializable_test.rb +8 -8
- data/test/models/timeoutable_test.rb +1 -1
- data/test/models/trackable_test.rb +28 -0
- data/test/models/validatable_test.rb +13 -13
- data/test/omniauth/config_test.rb +4 -4
- data/test/omniauth/url_helpers_test.rb +3 -3
- data/test/orm/mongoid.rb +1 -1
- data/test/parameter_sanitizer_test.rb +1 -1
- data/test/rails_app/app/active_record/shim.rb +1 -1
- data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
- data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -1
- data/test/rails_app/app/controllers/admins_controller.rb +1 -1
- data/test/rails_app/app/controllers/application_controller.rb +5 -2
- data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
- data/test/rails_app/app/controllers/custom/registrations_controller.rb +21 -0
- data/test/rails_app/app/controllers/home_controller.rb +1 -1
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -1
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -1
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +4 -4
- data/test/rails_app/app/controllers/users_controller.rb +6 -6
- data/test/rails_app/app/mailers/users/mailer.rb +4 -4
- data/test/rails_app/app/mongoid/admin.rb +11 -11
- data/test/rails_app/app/mongoid/shim.rb +2 -2
- data/test/rails_app/app/mongoid/user.rb +19 -19
- data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
- data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
- data/test/rails_app/app/views/admins/sessions/new.html.erb +1 -1
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -1
- data/test/rails_app/app/views/home/index.html.erb +1 -1
- data/test/rails_app/app/views/home/join.html.erb +1 -1
- data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -1
- data/test/rails_app/app/views/layouts/application.html.erb +1 -1
- data/test/rails_app/config/application.rb +2 -2
- data/test/rails_app/config/boot.rb +7 -1
- data/test/rails_app/config/environments/development.rb +0 -4
- data/test/rails_app/config/environments/production.rb +0 -4
- data/test/rails_app/config/initializers/devise.rb +7 -5
- data/test/rails_app/config/initializers/secret_token.rb +1 -1
- data/test/rails_app/config/routes.rb +60 -42
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +7 -7
- data/test/rails_app/db/schema.rb +21 -17
- data/test/rails_app/lib/shared_admin.rb +4 -4
- data/test/rails_app/lib/shared_user.rb +1 -1
- data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
- data/test/routes_test.rb +72 -58
- data/test/support/action_controller/record_identifier.rb +10 -0
- data/test/support/assertions.rb +2 -3
- data/test/support/helpers.rb +4 -4
- data/test/support/integration.rb +14 -14
- data/test/support/mongoid.yml +6 -0
- data/test/test_helper.rb +2 -7
- data/test/test_helpers_test.rb +25 -35
- data/test/test_models.rb +12 -5
- metadata +53 -38
- data/gemfiles/Gemfile.rails-3.2.x.lock +0 -159
@@ -8,16 +8,16 @@ class RegistrationTest < ActionDispatch::IntegrationTest
|
|
8
8
|
|
9
9
|
assert_template 'registrations/new'
|
10
10
|
|
11
|
-
fill_in 'email', :
|
12
|
-
fill_in 'password', :
|
13
|
-
fill_in 'password confirmation', :
|
11
|
+
fill_in 'email', with: 'new_user@test.com'
|
12
|
+
fill_in 'password', with: 'new_user123'
|
13
|
+
fill_in 'password confirmation', with: 'new_user123'
|
14
14
|
click_button 'Sign up'
|
15
15
|
|
16
16
|
assert_contain 'You have signed up successfully'
|
17
17
|
assert warden.authenticated?(:admin)
|
18
18
|
assert_current_url "/admin_area/home"
|
19
19
|
|
20
|
-
admin = Admin.order
|
20
|
+
admin = Admin.to_adapter.find_first(order: [:id, :desc])
|
21
21
|
assert_equal admin.email, 'new_user@test.com'
|
22
22
|
end
|
23
23
|
|
@@ -26,9 +26,9 @@ class RegistrationTest < ActionDispatch::IntegrationTest
|
|
26
26
|
get new_admin_session_path
|
27
27
|
click_link 'Sign up'
|
28
28
|
|
29
|
-
fill_in 'email', :
|
30
|
-
fill_in 'password', :
|
31
|
-
fill_in 'password confirmation', :
|
29
|
+
fill_in 'email', with: 'new_user@test.com'
|
30
|
+
fill_in 'password', with: 'new_user123'
|
31
|
+
fill_in 'password confirmation', with: 'new_user123'
|
32
32
|
click_button 'Sign up'
|
33
33
|
|
34
34
|
assert_contain 'Welcome! You have signed up successfully.'
|
@@ -36,27 +36,37 @@ class RegistrationTest < ActionDispatch::IntegrationTest
|
|
36
36
|
assert_current_url "/?custom=1"
|
37
37
|
end
|
38
38
|
|
39
|
+
test 'a guest admin should not see a warning about minimum password length' do
|
40
|
+
get new_admin_session_path
|
41
|
+
assert_not_contain 'characters minimum'
|
42
|
+
end
|
43
|
+
|
39
44
|
def user_sign_up
|
40
45
|
ActionMailer::Base.deliveries.clear
|
41
46
|
|
42
47
|
get new_user_registration_path
|
43
48
|
|
44
|
-
fill_in 'email', :
|
45
|
-
fill_in 'password', :
|
46
|
-
fill_in 'password confirmation', :
|
49
|
+
fill_in 'email', with: 'new_user@test.com'
|
50
|
+
fill_in 'password', with: 'new_user123'
|
51
|
+
fill_in 'password confirmation', with: 'new_user123'
|
47
52
|
click_button 'Sign up'
|
48
53
|
end
|
49
54
|
|
55
|
+
test 'a guest user should see a warning about minimum password length' do
|
56
|
+
get new_user_registration_path
|
57
|
+
assert_contain '7 characters minimum'
|
58
|
+
end
|
59
|
+
|
50
60
|
test 'a guest user should be able to sign up successfully and be blocked by confirmation' do
|
51
61
|
user_sign_up
|
52
62
|
|
53
|
-
assert_contain 'A message with a confirmation link has been sent to your email address. Please
|
63
|
+
assert_contain 'A message with a confirmation link has been sent to your email address. Please follow the link to activate your account.'
|
54
64
|
assert_not_contain 'You have to confirm your account before continuing'
|
55
65
|
assert_current_url "/"
|
56
66
|
|
57
67
|
assert_not warden.authenticated?(:user)
|
58
68
|
|
59
|
-
user = User.order
|
69
|
+
user = User.to_adapter.find_first(order: [:id, :desc])
|
60
70
|
assert_equal user.email, 'new_user@test.com'
|
61
71
|
assert_not user.confirmed?
|
62
72
|
end
|
@@ -76,9 +86,9 @@ class RegistrationTest < ActionDispatch::IntegrationTest
|
|
76
86
|
Devise::RegistrationsController.any_instance.stubs(:after_inactive_sign_up_path_for).returns("/?custom=1")
|
77
87
|
get new_user_registration_path
|
78
88
|
|
79
|
-
fill_in 'email', :
|
80
|
-
fill_in 'password', :
|
81
|
-
fill_in 'password confirmation', :
|
89
|
+
fill_in 'email', with: 'new_user@test.com'
|
90
|
+
fill_in 'password', with: 'new_user123'
|
91
|
+
fill_in 'password confirmation', with: 'new_user123'
|
82
92
|
click_button 'Sign up'
|
83
93
|
|
84
94
|
assert_current_url "/?custom=1"
|
@@ -92,9 +102,9 @@ class RegistrationTest < ActionDispatch::IntegrationTest
|
|
92
102
|
|
93
103
|
get new_user_registration_path
|
94
104
|
|
95
|
-
fill_in 'email', :
|
96
|
-
fill_in 'password', :
|
97
|
-
fill_in 'password confirmation', :
|
105
|
+
fill_in 'email', with: 'invalid_email'
|
106
|
+
fill_in 'password', with: 'new_user123'
|
107
|
+
fill_in 'password confirmation', with: 'new_user321'
|
98
108
|
click_button 'Sign up'
|
99
109
|
|
100
110
|
assert_template 'registrations/new'
|
@@ -103,7 +113,7 @@ class RegistrationTest < ActionDispatch::IntegrationTest
|
|
103
113
|
assert_contain Devise.rails4? ?
|
104
114
|
"Password confirmation doesn't match Password" : "Password doesn't match confirmation"
|
105
115
|
assert_contain "2 errors prohibited"
|
106
|
-
assert_nil User.
|
116
|
+
assert_nil User.to_adapter.find_first
|
107
117
|
|
108
118
|
assert_not warden.authenticated?(:user)
|
109
119
|
end
|
@@ -116,9 +126,9 @@ class RegistrationTest < ActionDispatch::IntegrationTest
|
|
116
126
|
create_user
|
117
127
|
get new_user_registration_path
|
118
128
|
|
119
|
-
fill_in 'email', :
|
120
|
-
fill_in 'password', :
|
121
|
-
fill_in 'password confirmation', :
|
129
|
+
fill_in 'email', with: 'user@test.com'
|
130
|
+
fill_in 'password', with: '123456'
|
131
|
+
fill_in 'password confirmation', with: '123456'
|
122
132
|
click_button 'Sign up'
|
123
133
|
|
124
134
|
assert_current_url '/users'
|
@@ -140,86 +150,86 @@ class RegistrationTest < ActionDispatch::IntegrationTest
|
|
140
150
|
assert_redirected_to root_path
|
141
151
|
end
|
142
152
|
|
143
|
-
test 'a signed in user should be able to edit
|
153
|
+
test 'a signed in user should be able to edit their account' do
|
144
154
|
sign_in_as_user
|
145
155
|
get edit_user_registration_path
|
146
156
|
|
147
|
-
fill_in 'email', :
|
148
|
-
fill_in 'current password', :
|
157
|
+
fill_in 'email', with: 'user.new@example.com'
|
158
|
+
fill_in 'current password', with: '12345678'
|
149
159
|
click_button 'Update'
|
150
160
|
|
151
161
|
assert_current_url '/'
|
152
|
-
assert_contain '
|
162
|
+
assert_contain 'Your account has been updated successfully.'
|
153
163
|
|
154
|
-
assert_equal "user.new@example.com", User.
|
164
|
+
assert_equal "user.new@example.com", User.to_adapter.find_first.email
|
155
165
|
end
|
156
166
|
|
157
|
-
test 'a signed in user should still be able to use the website after changing
|
167
|
+
test 'a signed in user should still be able to use the website after changing their password' do
|
158
168
|
sign_in_as_user
|
159
169
|
get edit_user_registration_path
|
160
170
|
|
161
|
-
fill_in 'password', :
|
162
|
-
fill_in 'password confirmation', :
|
163
|
-
fill_in 'current password', :
|
171
|
+
fill_in 'password', with: '1234567890'
|
172
|
+
fill_in 'password confirmation', with: '1234567890'
|
173
|
+
fill_in 'current password', with: '12345678'
|
164
174
|
click_button 'Update'
|
165
175
|
|
166
|
-
assert_contain '
|
176
|
+
assert_contain 'Your account has been updated successfully.'
|
167
177
|
get users_path
|
168
178
|
assert warden.authenticated?(:user)
|
169
179
|
end
|
170
180
|
|
171
|
-
test 'a signed in user should not change
|
181
|
+
test 'a signed in user should not change their current user with invalid password' do
|
172
182
|
sign_in_as_user
|
173
183
|
get edit_user_registration_path
|
174
184
|
|
175
|
-
fill_in 'email', :
|
176
|
-
fill_in 'current password', :
|
185
|
+
fill_in 'email', with: 'user.new@example.com'
|
186
|
+
fill_in 'current password', with: 'invalid'
|
177
187
|
click_button 'Update'
|
178
188
|
|
179
189
|
assert_template 'registrations/edit'
|
180
190
|
assert_contain 'user@test.com'
|
181
191
|
assert_have_selector 'form input[value="user.new@example.com"]'
|
182
192
|
|
183
|
-
assert_equal "user@test.com", User.
|
193
|
+
assert_equal "user@test.com", User.to_adapter.find_first.email
|
184
194
|
end
|
185
195
|
|
186
|
-
test 'a signed in user should be able to edit
|
196
|
+
test 'a signed in user should be able to edit their password' do
|
187
197
|
sign_in_as_user
|
188
198
|
get edit_user_registration_path
|
189
199
|
|
190
|
-
fill_in 'password', :
|
191
|
-
fill_in 'password confirmation', :
|
192
|
-
fill_in 'current password', :
|
200
|
+
fill_in 'password', with: 'pass1234'
|
201
|
+
fill_in 'password confirmation', with: 'pass1234'
|
202
|
+
fill_in 'current password', with: '12345678'
|
193
203
|
click_button 'Update'
|
194
204
|
|
195
205
|
assert_current_url '/'
|
196
|
-
assert_contain '
|
206
|
+
assert_contain 'Your account has been updated successfully.'
|
197
207
|
|
198
|
-
assert User.
|
208
|
+
assert User.to_adapter.find_first.valid_password?('pass1234')
|
199
209
|
end
|
200
210
|
|
201
|
-
test 'a signed in user should not be able to edit
|
211
|
+
test 'a signed in user should not be able to edit their password with invalid confirmation' do
|
202
212
|
sign_in_as_user
|
203
213
|
get edit_user_registration_path
|
204
214
|
|
205
|
-
fill_in 'password', :
|
206
|
-
fill_in 'password confirmation', :
|
207
|
-
fill_in 'current password', :
|
215
|
+
fill_in 'password', with: 'pas123'
|
216
|
+
fill_in 'password confirmation', with: ''
|
217
|
+
fill_in 'current password', with: '12345678'
|
208
218
|
click_button 'Update'
|
209
219
|
|
210
220
|
assert_contain Devise.rails4? ?
|
211
221
|
"Password confirmation doesn't match Password" : "Password doesn't match confirmation"
|
212
|
-
assert_not User.
|
222
|
+
assert_not User.to_adapter.find_first.valid_password?('pas123')
|
213
223
|
end
|
214
224
|
|
215
|
-
test 'a signed in user should be able to cancel
|
225
|
+
test 'a signed in user should be able to cancel their account' do
|
216
226
|
sign_in_as_user
|
217
227
|
get edit_user_registration_path
|
218
228
|
|
219
229
|
click_button "Cancel my account"
|
220
|
-
assert_contain "Bye! Your account
|
230
|
+
assert_contain "Bye! Your account has been successfully cancelled. We hope to see you again soon."
|
221
231
|
|
222
|
-
assert User.
|
232
|
+
assert User.to_adapter.find_all.empty?
|
223
233
|
end
|
224
234
|
|
225
235
|
test 'a user should be able to cancel sign up by deleting data in the session' do
|
@@ -235,77 +245,77 @@ class RegistrationTest < ActionDispatch::IntegrationTest
|
|
235
245
|
end
|
236
246
|
|
237
247
|
test 'a user with XML sign up stub' do
|
238
|
-
get new_user_registration_path(:
|
248
|
+
get new_user_registration_path(format: 'xml')
|
239
249
|
assert_response :success
|
240
250
|
assert_match %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>), response.body
|
241
251
|
assert_no_match(/<confirmation-token/, response.body)
|
242
252
|
end
|
243
253
|
|
244
254
|
test 'a user with JSON sign up stub' do
|
245
|
-
get new_user_registration_path(:
|
255
|
+
get new_user_registration_path(format: 'json')
|
246
256
|
assert_response :success
|
247
257
|
assert_match %({"user":), response.body
|
248
258
|
assert_no_match(/"confirmation_token"/, response.body)
|
249
259
|
end
|
250
260
|
|
251
261
|
test 'an admin sign up with valid information in XML format should return valid response' do
|
252
|
-
post admin_registration_path(:
|
262
|
+
post admin_registration_path(format: 'xml'), admin: { email: 'new_user@test.com', password: 'new_user123', password_confirmation: 'new_user123' }
|
253
263
|
assert_response :success
|
254
264
|
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<admin>)
|
255
265
|
|
256
|
-
admin = Admin.order
|
266
|
+
admin = Admin.to_adapter.find_first(order: [:id, :desc])
|
257
267
|
assert_equal admin.email, 'new_user@test.com'
|
258
268
|
end
|
259
269
|
|
260
270
|
test 'a user sign up with valid information in XML format should return valid response' do
|
261
|
-
post user_registration_path(:
|
271
|
+
post user_registration_path(format: 'xml'), user: { email: 'new_user@test.com', password: 'new_user123', password_confirmation: 'new_user123' }
|
262
272
|
assert_response :success
|
263
273
|
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
|
264
274
|
|
265
|
-
user = User.order
|
275
|
+
user = User.to_adapter.find_first(order: [:id, :desc])
|
266
276
|
assert_equal user.email, 'new_user@test.com'
|
267
277
|
end
|
268
278
|
|
269
279
|
test 'a user sign up with invalid information in XML format should return invalid response' do
|
270
|
-
post user_registration_path(:
|
280
|
+
post user_registration_path(format: 'xml'), user: { email: 'new_user@test.com', password: 'new_user123', password_confirmation: 'invalid' }
|
271
281
|
assert_response :unprocessable_entity
|
272
282
|
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
|
273
283
|
end
|
274
284
|
|
275
285
|
test 'a user update information with valid data in XML format should return valid response' do
|
276
286
|
user = sign_in_as_user
|
277
|
-
put user_registration_path(:
|
287
|
+
put user_registration_path(format: 'xml'), user: { current_password: '12345678', email: 'user.new@test.com' }
|
278
288
|
assert_response :success
|
279
289
|
assert_equal user.reload.email, 'user.new@test.com'
|
280
290
|
end
|
281
291
|
|
282
292
|
test 'a user update information with invalid data in XML format should return invalid response' do
|
283
293
|
user = sign_in_as_user
|
284
|
-
put user_registration_path(:
|
294
|
+
put user_registration_path(format: 'xml'), user: { current_password: 'invalid', email: 'user.new@test.com' }
|
285
295
|
assert_response :unprocessable_entity
|
286
296
|
assert_equal user.reload.email, 'user@test.com'
|
287
297
|
end
|
288
298
|
|
289
|
-
test 'a user cancel
|
299
|
+
test 'a user cancel their account in XML format should return valid response' do
|
290
300
|
sign_in_as_user
|
291
|
-
delete user_registration_path(:
|
301
|
+
delete user_registration_path(format: 'xml')
|
292
302
|
assert_response :success
|
293
|
-
assert_equal User.
|
303
|
+
assert_equal User.to_adapter.find_all.size, 0
|
294
304
|
end
|
295
305
|
end
|
296
306
|
|
297
307
|
class ReconfirmableRegistrationTest < ActionDispatch::IntegrationTest
|
298
|
-
test 'a signed in admin should see a more appropriate flash message when editing
|
308
|
+
test 'a signed in admin should see a more appropriate flash message when editing their account if reconfirmable is enabled' do
|
299
309
|
sign_in_as_admin
|
300
310
|
get edit_admin_registration_path
|
301
311
|
|
302
|
-
fill_in 'email', :
|
303
|
-
fill_in 'current password', :
|
312
|
+
fill_in 'email', with: 'admin.new@example.com'
|
313
|
+
fill_in 'current password', with: '123456'
|
304
314
|
click_button 'Update'
|
305
315
|
|
306
316
|
assert_current_url '/admin_area/home'
|
307
317
|
assert_contain 'but we need to verify your new email address'
|
308
|
-
assert_equal 'admin.new@example.com', Admin.
|
318
|
+
assert_equal 'admin.new@example.com', Admin.to_adapter.find_first.unconfirmed_email
|
309
319
|
|
310
320
|
get edit_admin_registration_path
|
311
321
|
assert_contain 'Currently waiting confirmation for: admin.new@example.com'
|
@@ -315,35 +325,35 @@ class ReconfirmableRegistrationTest < ActionDispatch::IntegrationTest
|
|
315
325
|
sign_in_as_admin
|
316
326
|
get edit_admin_registration_path
|
317
327
|
|
318
|
-
fill_in 'password', :
|
319
|
-
fill_in 'password confirmation', :
|
320
|
-
fill_in 'current password', :
|
328
|
+
fill_in 'password', with: 'pas123'
|
329
|
+
fill_in 'password confirmation', with: 'pas123'
|
330
|
+
fill_in 'current password', with: '123456'
|
321
331
|
click_button 'Update'
|
322
332
|
|
323
333
|
assert_current_url '/admin_area/home'
|
324
|
-
assert_contain '
|
334
|
+
assert_contain 'Your account has been updated successfully.'
|
325
335
|
|
326
|
-
assert Admin.
|
336
|
+
assert Admin.to_adapter.find_first.valid_password?('pas123')
|
327
337
|
end
|
328
338
|
|
329
|
-
test 'a signed in admin should not see a reconfirmation message if
|
339
|
+
test 'a signed in admin should not see a reconfirmation message if they did not change their email, despite having an unconfirmed email' do
|
330
340
|
sign_in_as_admin
|
331
341
|
|
332
342
|
get edit_admin_registration_path
|
333
|
-
fill_in 'email', :
|
334
|
-
fill_in 'current password', :
|
343
|
+
fill_in 'email', with: 'admin.new@example.com'
|
344
|
+
fill_in 'current password', with: '123456'
|
335
345
|
click_button 'Update'
|
336
346
|
|
337
347
|
get edit_admin_registration_path
|
338
|
-
fill_in 'password', :
|
339
|
-
fill_in 'password confirmation', :
|
340
|
-
fill_in 'current password', :
|
348
|
+
fill_in 'password', with: 'pas123'
|
349
|
+
fill_in 'password confirmation', with: 'pas123'
|
350
|
+
fill_in 'current password', with: '123456'
|
341
351
|
click_button 'Update'
|
342
352
|
|
343
353
|
assert_current_url '/admin_area/home'
|
344
|
-
assert_contain '
|
354
|
+
assert_contain 'Your account has been updated successfully.'
|
345
355
|
|
346
|
-
assert_equal "admin.new@example.com", Admin.
|
347
|
-
assert Admin.
|
356
|
+
assert_equal "admin.new@example.com", Admin.to_adapter.find_first.unconfirmed_email
|
357
|
+
assert Admin.to_adapter.find_first.valid_password?('pas123')
|
348
358
|
end
|
349
359
|
end
|
@@ -25,13 +25,13 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
25
25
|
Time.parse(expires).utc
|
26
26
|
end
|
27
27
|
|
28
|
-
test 'do not remember the user if
|
28
|
+
test 'do not remember the user if they have not checked remember me option' do
|
29
29
|
sign_in_as_user
|
30
30
|
assert_nil request.cookies["remember_user_cookie"]
|
31
31
|
end
|
32
32
|
|
33
33
|
test 'handle unverified requests gets rid of caches' do
|
34
|
-
swap ApplicationController, :
|
34
|
+
swap ApplicationController, allow_forgery_protection: true do
|
35
35
|
post exhibit_user_url(1)
|
36
36
|
assert_not warden.authenticated?(:user)
|
37
37
|
|
@@ -43,19 +43,19 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
43
43
|
end
|
44
44
|
|
45
45
|
test 'handle unverified requests does not create cookies on sign in' do
|
46
|
-
swap ApplicationController, :
|
46
|
+
swap ApplicationController, allow_forgery_protection: true do
|
47
47
|
get new_user_session_path
|
48
48
|
assert request.session[:_csrf_token]
|
49
49
|
|
50
|
-
post user_session_path, :
|
51
|
-
{ email: "jose.valim@gmail.com", password: "123456", :
|
50
|
+
post user_session_path, authenticity_token: "oops", user:
|
51
|
+
{ email: "jose.valim@gmail.com", password: "123456", remember_me: "1" }
|
52
52
|
assert_not warden.authenticated?(:user)
|
53
53
|
assert_not request.cookies['remember_user_token']
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
test 'generate remember token after sign in' do
|
58
|
-
sign_in_as_user :
|
58
|
+
sign_in_as_user remember_me: true
|
59
59
|
assert request.cookies['remember_user_token']
|
60
60
|
end
|
61
61
|
|
@@ -63,15 +63,15 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
63
63
|
# We test this by asserting the cookie is not sent after the redirect
|
64
64
|
# since we changed the domain. This is the only difference with the
|
65
65
|
# previous test.
|
66
|
-
swap Devise, :
|
67
|
-
sign_in_as_user :
|
66
|
+
swap Devise, rememberable_options: { domain: "omg.somewhere.com" } do
|
67
|
+
sign_in_as_user remember_me: true
|
68
68
|
assert_nil request.cookies["remember_user_token"]
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
test 'generate remember token with a custom key' do
|
73
|
-
swap Devise, :
|
74
|
-
sign_in_as_user :
|
73
|
+
swap Devise, rememberable_options: { key: "v1lat_token" } do
|
74
|
+
sign_in_as_user remember_me: true
|
75
75
|
assert request.cookies["v1lat_token"]
|
76
76
|
end
|
77
77
|
end
|
@@ -79,7 +79,7 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
79
79
|
test 'generate remember token after sign in setting session options' do
|
80
80
|
begin
|
81
81
|
Rails.configuration.session_options[:domain] = "omg.somewhere.com"
|
82
|
-
sign_in_as_user :
|
82
|
+
sign_in_as_user remember_me: true
|
83
83
|
assert_nil request.cookies["remember_user_token"]
|
84
84
|
ensure
|
85
85
|
Rails.configuration.session_options.delete(:domain)
|
@@ -95,7 +95,7 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
95
95
|
assert_match /remember_user_token[^\n]*HttpOnly/, response.headers["Set-Cookie"], "Expected Set-Cookie header in response to set HttpOnly flag on remember_user_token cookie."
|
96
96
|
end
|
97
97
|
|
98
|
-
test 'remember the user before sign up and redirect
|
98
|
+
test 'remember the user before sign up and redirect them to their home' do
|
99
99
|
create_user_and_remember
|
100
100
|
get new_user_registration_path
|
101
101
|
assert warden.authenticated?(:user)
|
@@ -103,14 +103,14 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
103
103
|
end
|
104
104
|
|
105
105
|
test 'does not extend remember period through sign in' do
|
106
|
-
swap Devise, :
|
106
|
+
swap Devise, extend_remember_period: true, remember_for: 1.year do
|
107
107
|
user = create_user
|
108
108
|
user.remember_me!
|
109
109
|
|
110
110
|
user.remember_created_at = old = 10.days.ago
|
111
111
|
user.save
|
112
112
|
|
113
|
-
sign_in_as_user :
|
113
|
+
sign_in_as_user remember_me: true
|
114
114
|
user.reload
|
115
115
|
|
116
116
|
assert warden.user(:user) == user
|
@@ -135,7 +135,7 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
135
135
|
|
136
136
|
test 'do not remember with expired token' do
|
137
137
|
create_user_and_remember
|
138
|
-
swap Devise, :
|
138
|
+
swap Devise, remember_for: 0 do
|
139
139
|
get users_path
|
140
140
|
assert_not warden.authenticated?(:user)
|
141
141
|
assert_redirected_to new_user_session_path
|
@@ -8,12 +8,11 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
8
8
|
|
9
9
|
test 'set last request at in user session after each request' do
|
10
10
|
sign_in_as_user
|
11
|
-
old_last_request = last_request_at
|
12
11
|
assert_not_nil last_request_at
|
13
12
|
|
13
|
+
@controller.user_session.delete('last_request_at')
|
14
14
|
get users_path
|
15
15
|
assert_not_nil last_request_at
|
16
|
-
assert_not_equal old_last_request, last_request_at
|
17
16
|
end
|
18
17
|
|
19
18
|
test 'set last request at in user session after each request is skipped if tracking is disabled' do
|
@@ -35,14 +34,19 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
35
34
|
assert warden.authenticated?(:user)
|
36
35
|
end
|
37
36
|
|
38
|
-
test 'time out user session after default limit time' do
|
39
|
-
|
40
|
-
|
41
|
-
assert_not_nil last_request_at
|
37
|
+
test 'time out user session after default limit time when sign_out_all_scopes is false' do
|
38
|
+
swap Devise, sign_out_all_scopes: false do
|
39
|
+
sign_in_as_admin
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
user = sign_in_as_user
|
42
|
+
get expire_user_path(user)
|
43
|
+
assert_not_nil last_request_at
|
44
|
+
|
45
|
+
get users_path
|
46
|
+
assert_redirected_to users_path
|
47
|
+
assert_not warden.authenticated?(:user)
|
48
|
+
assert warden.authenticated?(:admin)
|
49
|
+
end
|
46
50
|
end
|
47
51
|
|
48
52
|
test 'time out all sessions after default limit time when sign_out_all_scopes is true' do
|
@@ -99,7 +103,7 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
99
103
|
user = sign_in_as_user
|
100
104
|
get expire_user_path(user)
|
101
105
|
|
102
|
-
post "/users/sign_in", :
|
106
|
+
post "/users/sign_in", email: user.email, password: "123456"
|
103
107
|
|
104
108
|
assert_response :redirect
|
105
109
|
follow_redirect!
|
@@ -124,7 +128,7 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
124
128
|
end
|
125
129
|
|
126
130
|
test 'user configured timeout limit' do
|
127
|
-
swap Devise, :
|
131
|
+
swap Devise, timeout_in: 8.minutes do
|
128
132
|
user = sign_in_as_user
|
129
133
|
|
130
134
|
get users_path
|
@@ -140,8 +144,8 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
140
144
|
end
|
141
145
|
|
142
146
|
test 'error message with i18n' do
|
143
|
-
store_translations :en, :
|
144
|
-
:
|
147
|
+
store_translations :en, devise: {
|
148
|
+
failure: { user: { timeout: 'Session expired!' } }
|
145
149
|
} do
|
146
150
|
user = sign_in_as_user
|
147
151
|
|
@@ -153,8 +157,8 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
153
157
|
end
|
154
158
|
|
155
159
|
test 'error message with i18n with double redirect' do
|
156
|
-
store_translations :en, :
|
157
|
-
:
|
160
|
+
store_translations :en, devise: {
|
161
|
+
failure: { user: { timeout: 'Session expired!' } }
|
158
162
|
} do
|
159
163
|
user = sign_in_as_user
|
160
164
|
|
@@ -167,7 +171,7 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
167
171
|
end
|
168
172
|
|
169
173
|
test 'time out not triggered if remembered' do
|
170
|
-
user = sign_in_as_user :
|
174
|
+
user = sign_in_as_user remember_me: true
|
171
175
|
get expire_user_path(user)
|
172
176
|
assert_not_nil last_request_at
|
173
177
|
|
@@ -175,4 +179,11 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
175
179
|
assert_response :success
|
176
180
|
assert warden.authenticated?(:user)
|
177
181
|
end
|
182
|
+
|
183
|
+
test 'does not crashes when the last_request_at is a String' do
|
184
|
+
user = sign_in_as_user
|
185
|
+
|
186
|
+
get edit_form_user_path(user, last_request_at: Time.now.utc.to_s)
|
187
|
+
get users_path
|
188
|
+
end
|
178
189
|
end
|
@@ -10,8 +10,8 @@ class TrackableHooksTest < ActionDispatch::IntegrationTest
|
|
10
10
|
sign_in_as_user
|
11
11
|
user.reload
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
assert user.current_sign_in_at.acts_like?(:time)
|
14
|
+
assert user.last_sign_in_at.acts_like?(:time)
|
15
15
|
|
16
16
|
assert_equal user.current_sign_in_at, user.last_sign_in_at
|
17
17
|
assert user.current_sign_in_at >= user.created_at
|
@@ -63,8 +63,8 @@ class TrackableHooksTest < ActionDispatch::IntegrationTest
|
|
63
63
|
end
|
64
64
|
|
65
65
|
test "does not update anything if user has signed out along the way" do
|
66
|
-
swap Devise, :
|
67
|
-
user = create_user(:
|
66
|
+
swap Devise, allow_unconfirmed_access_for: 0.days do
|
67
|
+
user = create_user(confirm: false)
|
68
68
|
sign_in_as_user
|
69
69
|
|
70
70
|
user.reload
|