devise 3.2.4 → 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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +12 -5
  4. data/CHANGELOG.md +28 -1
  5. data/Gemfile +5 -5
  6. data/Gemfile.lock +98 -92
  7. data/README.md +22 -16
  8. data/app/controllers/devise/confirmations_controller.rb +1 -1
  9. data/app/controllers/devise/registrations_controller.rb +18 -5
  10. data/app/controllers/devise/sessions_controller.rb +32 -9
  11. data/app/controllers/devise_controller.rb +3 -3
  12. data/app/views/devise/registrations/new.html.erb +1 -1
  13. data/app/views/devise/sessions/new.html.erb +2 -2
  14. data/app/views/devise/shared/_links.erb +1 -1
  15. data/config/locales/en.yml +16 -15
  16. data/gemfiles/Gemfile.rails-3.2-stable +3 -3
  17. data/gemfiles/Gemfile.rails-3.2-stable.lock +166 -0
  18. data/gemfiles/Gemfile.rails-4.0-stable +4 -4
  19. data/gemfiles/Gemfile.rails-4.0-stable.lock +162 -0
  20. data/gemfiles/Gemfile.rails-head +7 -4
  21. data/gemfiles/Gemfile.rails-head.lock +190 -0
  22. data/lib/devise.rb +8 -4
  23. data/lib/devise/controllers/helpers.rb +77 -6
  24. data/lib/devise/controllers/sign_in_out.rb +0 -1
  25. data/lib/devise/controllers/store_location.rb +8 -2
  26. data/lib/devise/controllers/url_helpers.rb +3 -1
  27. data/lib/devise/failure_app.rb +6 -6
  28. data/lib/devise/hooks/activatable.rb +3 -4
  29. data/lib/devise/hooks/csrf_cleaner.rb +3 -1
  30. data/lib/devise/hooks/timeoutable.rb +8 -1
  31. data/lib/devise/mapping.rb +4 -1
  32. data/lib/devise/models/confirmable.rb +3 -3
  33. data/lib/devise/models/database_authenticatable.rb +7 -3
  34. data/lib/devise/models/lockable.rb +2 -2
  35. data/lib/devise/models/recoverable.rb +23 -7
  36. data/lib/devise/models/rememberable.rb +2 -2
  37. data/lib/devise/models/trackable.rb +4 -1
  38. data/lib/devise/rails/routes.rb +8 -6
  39. data/lib/devise/strategies/authenticatable.rb +7 -0
  40. data/lib/devise/version.rb +1 -1
  41. data/lib/generators/active_record/devise_generator.rb +19 -2
  42. data/lib/generators/templates/README +1 -1
  43. data/lib/generators/templates/devise.rb +3 -0
  44. data/script/cached-bundle +49 -0
  45. data/script/s3-put +71 -0
  46. data/test/controllers/custom_registrations_controller_test.rb +35 -0
  47. data/test/controllers/helpers_test.rb +35 -0
  48. data/test/controllers/internal_helpers_test.rb +1 -1
  49. data/test/controllers/passwords_controller_test.rb +1 -1
  50. data/test/devise_test.rb +18 -5
  51. data/test/failure_app_test.rb +40 -4
  52. data/test/generators/active_record_generator_test.rb +6 -0
  53. data/test/helpers/devise_helper_test.rb +3 -2
  54. data/test/integration/authenticatable_test.rb +19 -3
  55. data/test/integration/confirmable_test.rb +49 -9
  56. data/test/integration/http_authenticatable_test.rb +1 -1
  57. data/test/integration/lockable_test.rb +6 -6
  58. data/test/integration/recoverable_test.rb +5 -5
  59. data/test/integration/registerable_test.rb +32 -22
  60. data/test/integration/timeoutable_test.rb +8 -2
  61. data/test/integration/trackable_test.rb +2 -2
  62. data/test/mailers/confirmation_instructions_test.rb +3 -3
  63. data/test/mailers/reset_password_instructions_test.rb +3 -3
  64. data/test/mailers/unlock_instructions_test.rb +3 -3
  65. data/test/models/authenticatable_test.rb +1 -1
  66. data/test/models/lockable_test.rb +6 -0
  67. data/test/models/recoverable_test.rb +12 -0
  68. data/test/models/rememberable_test.rb +21 -6
  69. data/test/models/trackable_test.rb +28 -0
  70. data/test/models/validatable_test.rb +2 -2
  71. data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
  72. data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
  73. data/test/rails_app/app/controllers/application_controller.rb +3 -0
  74. data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
  75. data/test/rails_app/app/controllers/custom/registrations_controller.rb +21 -0
  76. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +1 -1
  77. data/test/rails_app/app/controllers/users_controller.rb +1 -1
  78. data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
  79. data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
  80. data/test/rails_app/config/application.rb +1 -1
  81. data/test/rails_app/config/initializers/devise.rb +2 -0
  82. data/test/rails_app/config/routes.rb +17 -0
  83. data/test/rails_app/lib/shared_user.rb +1 -1
  84. data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
  85. data/test/routes_test.rb +5 -3
  86. data/test/support/assertions.rb +2 -3
  87. data/test/support/integration.rb +2 -2
  88. data/test/test_helper.rb +2 -0
  89. data/test/test_helpers_test.rb +22 -32
  90. metadata +23 -2
@@ -42,7 +42,7 @@ class HttpAuthenticationTest < ActionDispatch::IntegrationTest
42
42
  sign_in_as_new_user_with_http("unknown")
43
43
  assert_equal 401, status
44
44
  assert_equal "application/xml; charset=utf-8", headers["Content-Type"]
45
- assert_match "<error>Invalid email or password.</error>", response.body
45
+ assert_match "<error>Invalid email address or password.</error>", response.body
46
46
  end
47
47
 
48
48
  test 'returns a custom response with www-authenticate and chosen realm' do
@@ -22,7 +22,7 @@ class LockTest < ActionDispatch::IntegrationTest
22
22
  send_unlock_request
23
23
 
24
24
  assert_template 'sessions/new'
25
- assert_contain 'You will receive an email with instructions about how to unlock your account in a few minutes'
25
+ assert_contain 'You will receive an email with instructions for how to unlock your account in a few minutes'
26
26
 
27
27
  mail = ActionMailer::Base.deliveries.last
28
28
  assert_equal 1, ActionMailer::Base.deliveries.size
@@ -182,7 +182,7 @@ class LockTest < ActionDispatch::IntegrationTest
182
182
  click_button 'Resend unlock instructions'
183
183
 
184
184
  assert_current_url "/users/sign_in"
185
- assert_contain "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
185
+ assert_contain "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
186
186
  end
187
187
  end
188
188
 
@@ -197,7 +197,7 @@ class LockTest < ActionDispatch::IntegrationTest
197
197
  click_button 'Resend unlock instructions'
198
198
 
199
199
  assert_current_url "/users/sign_in"
200
- assert_contain "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
200
+ assert_contain "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
201
201
  end
202
202
  end
203
203
 
@@ -213,7 +213,7 @@ class LockTest < ActionDispatch::IntegrationTest
213
213
  assert_not_contain "Email not found"
214
214
  assert_current_url "/users/sign_in"
215
215
 
216
- assert_contain "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
216
+ assert_contain "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
217
217
 
218
218
  end
219
219
  end
@@ -225,11 +225,11 @@ class LockTest < ActionDispatch::IntegrationTest
225
225
  visit new_user_session_path
226
226
  fill_in 'email', with: user.email
227
227
  fill_in 'password', with: "abadpassword"
228
- click_button 'Sign in'
228
+ click_button 'Log in'
229
229
 
230
230
  fill_in 'email', with: user.email
231
231
  fill_in 'password', with: "abadpassword"
232
- click_button 'Sign in'
232
+ click_button 'Log in'
233
233
 
234
234
  assert_current_url "/users/sign_in"
235
235
  assert_not_contain "locked"
@@ -171,7 +171,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
171
171
  reset_password
172
172
 
173
173
  assert_current_url '/'
174
- assert_contain 'Your password was changed successfully. You are now signed in.'
174
+ assert_contain 'Your password has been changed successfully. You are now signed in.'
175
175
  assert user.reload.valid_password?('987654321')
176
176
  end
177
177
 
@@ -185,7 +185,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
185
185
  assert_not user.reload.valid_password?('987654321')
186
186
 
187
187
  reset_password visit: false
188
- assert_contain 'Your password was changed successfully.'
188
+ assert_contain 'Your password has been changed successfully.'
189
189
  assert user.reload.valid_password?('987654321')
190
190
  end
191
191
 
@@ -204,7 +204,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
204
204
  request_forgot_password
205
205
  reset_password
206
206
 
207
- assert_contain 'Your password was changed successfully.'
207
+ assert_contain 'Your password has been changed successfully.'
208
208
  assert_not_contain 'You are now signed in.'
209
209
  assert_equal new_user_session_path, @request.path
210
210
  assert !warden.authenticated?(:user)
@@ -218,7 +218,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
218
218
  request_forgot_password
219
219
  reset_password
220
220
 
221
- assert_contain 'Your password was changed successfully.'
221
+ assert_contain 'Your password has been changed successfully.'
222
222
  assert !user.reload.access_locked?
223
223
  assert warden.authenticated?(:user)
224
224
  end
@@ -230,7 +230,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
230
230
  request_forgot_password
231
231
  reset_password
232
232
 
233
- assert_contain 'Your password was changed successfully.'
233
+ assert_contain 'Your password has been changed successfully.'
234
234
  assert !user.reload.access_locked?
235
235
  assert warden.authenticated?(:user)
236
236
  end
@@ -17,7 +17,7 @@ class RegistrationTest < ActionDispatch::IntegrationTest
17
17
  assert warden.authenticated?(:admin)
18
18
  assert_current_url "/admin_area/home"
19
19
 
20
- admin = Admin.order(:id).last
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
 
@@ -36,6 +36,11 @@ 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
 
@@ -47,16 +52,21 @@ class RegistrationTest < ActionDispatch::IntegrationTest
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 open the link to activate your account.'
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(:id).last
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
@@ -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.first
116
+ assert_nil User.to_adapter.find_first
107
117
 
108
118
  assert_not warden.authenticated?(:user)
109
119
  end
@@ -149,9 +159,9 @@ class RegistrationTest < ActionDispatch::IntegrationTest
149
159
  click_button 'Update'
150
160
 
151
161
  assert_current_url '/'
152
- assert_contain 'You updated your account successfully.'
162
+ assert_contain 'Your account has been updated successfully.'
153
163
 
154
- assert_equal "user.new@example.com", User.first.email
164
+ assert_equal "user.new@example.com", User.to_adapter.find_first.email
155
165
  end
156
166
 
157
167
  test 'a signed in user should still be able to use the website after changing their password' do
@@ -163,7 +173,7 @@ class RegistrationTest < ActionDispatch::IntegrationTest
163
173
  fill_in 'current password', with: '12345678'
164
174
  click_button 'Update'
165
175
 
166
- assert_contain 'You updated your account successfully.'
176
+ assert_contain 'Your account has been updated successfully.'
167
177
  get users_path
168
178
  assert warden.authenticated?(:user)
169
179
  end
@@ -180,7 +190,7 @@ class RegistrationTest < ActionDispatch::IntegrationTest
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.first.email
193
+ assert_equal "user@test.com", User.to_adapter.find_first.email
184
194
  end
185
195
 
186
196
  test 'a signed in user should be able to edit their password' do
@@ -193,9 +203,9 @@ class RegistrationTest < ActionDispatch::IntegrationTest
193
203
  click_button 'Update'
194
204
 
195
205
  assert_current_url '/'
196
- assert_contain 'You updated your account successfully.'
206
+ assert_contain 'Your account has been updated successfully.'
197
207
 
198
- assert User.first.valid_password?('pass1234')
208
+ assert User.to_adapter.find_first.valid_password?('pass1234')
199
209
  end
200
210
 
201
211
  test 'a signed in user should not be able to edit their password with invalid confirmation' do
@@ -209,7 +219,7 @@ class RegistrationTest < ActionDispatch::IntegrationTest
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.first.valid_password?('pas123')
222
+ assert_not User.to_adapter.find_first.valid_password?('pas123')
213
223
  end
214
224
 
215
225
  test 'a signed in user should be able to cancel their account' do
@@ -217,9 +227,9 @@ class RegistrationTest < ActionDispatch::IntegrationTest
217
227
  get edit_user_registration_path
218
228
 
219
229
  click_button "Cancel my account"
220
- assert_contain "Bye! Your account was successfully cancelled. We hope to see you again soon."
230
+ assert_contain "Bye! Your account has been successfully cancelled. We hope to see you again soon."
221
231
 
222
- assert User.all.empty?
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
@@ -253,7 +263,7 @@ class RegistrationTest < ActionDispatch::IntegrationTest
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(:id).last
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
 
@@ -262,7 +272,7 @@ class RegistrationTest < ActionDispatch::IntegrationTest
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(:id).last
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
 
@@ -290,7 +300,7 @@ class RegistrationTest < ActionDispatch::IntegrationTest
290
300
  sign_in_as_user
291
301
  delete user_registration_path(format: 'xml')
292
302
  assert_response :success
293
- assert_equal User.count, 0
303
+ assert_equal User.to_adapter.find_all.size, 0
294
304
  end
295
305
  end
296
306
 
@@ -305,7 +315,7 @@ class ReconfirmableRegistrationTest < ActionDispatch::IntegrationTest
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.first.unconfirmed_email
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'
@@ -321,9 +331,9 @@ class ReconfirmableRegistrationTest < ActionDispatch::IntegrationTest
321
331
  click_button 'Update'
322
332
 
323
333
  assert_current_url '/admin_area/home'
324
- assert_contain 'You updated your account successfully.'
334
+ assert_contain 'Your account has been updated successfully.'
325
335
 
326
- assert Admin.first.valid_password?('pas123')
336
+ assert Admin.to_adapter.find_first.valid_password?('pas123')
327
337
  end
328
338
 
329
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
@@ -341,9 +351,9 @@ class ReconfirmableRegistrationTest < ActionDispatch::IntegrationTest
341
351
  click_button 'Update'
342
352
 
343
353
  assert_current_url '/admin_area/home'
344
- assert_contain 'You updated your account successfully.'
354
+ assert_contain 'Your account has been updated successfully.'
345
355
 
346
- assert_equal "admin.new@example.com", Admin.first.unconfirmed_email
347
- assert Admin.first.valid_password?('pas123')
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
@@ -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
@@ -180,4 +179,11 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
180
179
  assert_response :success
181
180
  assert warden.authenticated?(:user)
182
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
183
189
  end
@@ -10,8 +10,8 @@ class TrackableHooksTest < ActionDispatch::IntegrationTest
10
10
  sign_in_as_user
11
11
  user.reload
12
12
 
13
- assert_kind_of Time, user.current_sign_in_at
14
- assert_kind_of Time, user.last_sign_in_at
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
@@ -53,7 +53,7 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
53
53
 
54
54
  test 'custom mailer renders parent mailer template' do
55
55
  Devise.mailer = 'Users::Mailer'
56
- assert_not_blank mail.body.encoded
56
+ assert_present mail.body.encoded
57
57
  end
58
58
 
59
59
  test 'setup reply to as copy from sender' do
@@ -83,9 +83,9 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
83
83
  end
84
84
 
85
85
  test 'body should have link to confirm the account' do
86
- host = ActionMailer::Base.default_url_options[:host]
86
+ host, port = ActionMailer::Base.default_url_options.values_at :host, :port
87
87
 
88
- if mail.body.encoded =~ %r{<a href=\"http://#{host}/users/confirmation\?confirmation_token=([^"]+)">}
88
+ if mail.body.encoded =~ %r{<a href=\"http://#{host}:#{port}/users/confirmation\?confirmation_token=([^"]+)">}
89
89
  assert_equal Devise.token_generator.digest(user.class, :confirmation_token, $1), user.confirmation_token
90
90
  else
91
91
  flunk "expected confirmation url regex to match"
@@ -55,7 +55,7 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
55
55
 
56
56
  test 'custom mailer renders parent mailer template' do
57
57
  Devise.mailer = 'Users::Mailer'
58
- assert_not_blank mail.body.encoded
58
+ assert_present mail.body.encoded
59
59
  end
60
60
 
61
61
  test 'setup reply to as copy from sender' do
@@ -79,9 +79,9 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
79
79
  end
80
80
 
81
81
  test 'body should have link to confirm the account' do
82
- host = ActionMailer::Base.default_url_options[:host]
82
+ host, port = ActionMailer::Base.default_url_options.values_at :host, :port
83
83
 
84
- if mail.body.encoded =~ %r{<a href=\"http://#{host}/users/password/edit\?reset_password_token=([^"]+)">}
84
+ if mail.body.encoded =~ %r{<a href=\"http://#{host}:#{port}/users/password/edit\?reset_password_token=([^"]+)">}
85
85
  assert_equal Devise.token_generator.digest(user.class, :reset_password_token, $1), user.reset_password_token
86
86
  else
87
87
  flunk "expected reset password url regex to match"
@@ -56,7 +56,7 @@ class UnlockInstructionsTest < ActionMailer::TestCase
56
56
 
57
57
  test 'custom mailer renders parent mailer template' do
58
58
  Devise.mailer = 'Users::Mailer'
59
- assert_not_blank mail.body.encoded
59
+ assert_present mail.body.encoded
60
60
  end
61
61
 
62
62
  test 'setup reply to as copy from sender' do
@@ -80,9 +80,9 @@ class UnlockInstructionsTest < ActionMailer::TestCase
80
80
  end
81
81
 
82
82
  test 'body should have link to unlock the account' do
83
- host = ActionMailer::Base.default_url_options[:host]
83
+ host, port = ActionMailer::Base.default_url_options.values_at :host, :port
84
84
 
85
- if mail.body.encoded =~ %r{<a href=\"http://#{host}/users/unlock\?unlock_token=([^"]+)">}
85
+ if mail.body.encoded =~ %r{<a href=\"http://#{host}:#{port}/users/unlock\?unlock_token=([^"]+)">}
86
86
  assert_equal Devise.token_generator.digest(user.class, :unlock_token, $1), user.unlock_token
87
87
  else
88
88
  flunk "expected unlock url regex to match"
@@ -6,7 +6,7 @@ class AuthenticatableTest < ActiveSupport::TestCase
6
6
  end
7
7
 
8
8
  test 'find_first_by_auth_conditions allows custom filtering parameters' do
9
- user = User.create!(email: "example@example.com", password: "123456")
9
+ user = User.create!(email: "example@example.com", password: "1234567")
10
10
  assert_equal User.find_first_by_auth_conditions({ email: "example@example.com" }), user
11
11
  assert_nil User.find_first_by_auth_conditions({ email: "example@example.com" }, id: user.id.to_s.next)
12
12
  end
@@ -313,4 +313,10 @@ class LockableTest < ActiveSupport::TestCase
313
313
  end
314
314
  end
315
315
  end
316
+
317
+ test 'should return locked message if user was programatically locked' do
318
+ user = create_user
319
+ user.lock_access!
320
+ assert_equal :locked, user.unauthenticated_message
321
+ end
316
322
  end
@@ -181,4 +181,16 @@ class RecoverableTest < ActiveSupport::TestCase
181
181
  :reset_password_token
182
182
  ]
183
183
  end
184
+
185
+ test 'should return a user based on the raw token' do
186
+ user = create_user
187
+ raw = user.send_reset_password_instructions
188
+
189
+ assert_equal User.with_reset_password_token(raw), user
190
+ end
191
+
192
+ test 'should return nil if a user based on the raw token is not found' do
193
+ assert_equal User.with_reset_password_token('random-token'), nil
194
+ end
195
+
184
196
  end
@@ -55,12 +55,27 @@ class RememberableTest < ActiveSupport::TestCase
55
55
  assert resource_class.new.respond_to?(:remember_me=)
56
56
  end
57
57
 
58
- test 'forget_me should clear remember_created_at' do
59
- resource = create_resource
60
- resource.remember_me!
61
- assert_not resource.remember_created_at.nil?
62
- resource.forget_me!
63
- assert resource.remember_created_at.nil?
58
+ test 'forget_me should clear remember_created_at if expire_all_remember_me_on_sign_out is true' do
59
+ swap Devise, expire_all_remember_me_on_sign_out: true do
60
+ resource = create_resource
61
+ resource.remember_me!
62
+ assert_not_nil resource.remember_created_at
63
+
64
+ resource.forget_me!
65
+ assert_nil resource.remember_created_at
66
+ end
67
+ end
68
+
69
+ test 'forget_me should not clear remember_created_at if expire_all_remember_me_on_sign_out is false' do
70
+ swap Devise, expire_all_remember_me_on_sign_out: false do
71
+ resource = create_resource
72
+ resource.remember_me!
73
+
74
+ assert_not_nil resource.remember_created_at
75
+
76
+ resource.forget_me!
77
+ assert_not_nil resource.remember_created_at
78
+ end
64
79
  end
65
80
 
66
81
  test 'forget_me should not try to update resource if it has been destroyed' do