devise 3.0.4 → 3.1.0.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise might be problematic. Click here for more details.

Files changed (52) hide show
  1. data/{CHANGELOG.rdoc → CHANGELOG.md} +41 -30
  2. data/Gemfile.lock +14 -13
  3. data/README.md +12 -11
  4. data/app/controllers/devise/confirmations_controller.rb +6 -2
  5. data/app/controllers/devise/registrations_controller.rb +2 -2
  6. data/app/controllers/devise/sessions_controller.rb +1 -1
  7. data/app/mailers/devise/mailer.rb +6 -3
  8. data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
  9. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  10. data/app/views/devise/mailer/unlock_instructions.html.erb +1 -1
  11. data/app/views/devise/shared/_links.erb +2 -2
  12. data/config/locales/en.yml +2 -2
  13. data/devise.gemspec +1 -0
  14. data/gemfiles/Gemfile.rails-3.2.x.lock +45 -42
  15. data/lib/devise.rb +20 -13
  16. data/lib/devise/controllers/helpers.rb +1 -0
  17. data/lib/devise/hooks/rememberable.rb +2 -1
  18. data/lib/devise/mailers/helpers.rb +0 -6
  19. data/lib/devise/models.rb +8 -12
  20. data/lib/devise/models/authenticatable.rb +8 -16
  21. data/lib/devise/models/confirmable.rb +27 -37
  22. data/lib/devise/models/lockable.rb +15 -17
  23. data/lib/devise/models/recoverable.rb +21 -27
  24. data/lib/devise/models/token_authenticatable.rb +4 -1
  25. data/lib/devise/parameter_sanitizer.rb +49 -19
  26. data/lib/devise/rails.rb +7 -11
  27. data/lib/devise/rails/routes.rb +12 -9
  28. data/lib/devise/rails/warden_compat.rb +1 -0
  29. data/lib/devise/strategies/authenticatable.rb +0 -12
  30. data/lib/devise/strategies/database_authenticatable.rb +3 -6
  31. data/lib/devise/token_generator.rb +70 -0
  32. data/lib/devise/version.rb +1 -1
  33. data/lib/generators/templates/devise.rb +14 -8
  34. data/test/controllers/passwords_controller_test.rb +3 -4
  35. data/test/failure_app_test.rb +1 -1
  36. data/test/integration/confirmable_test.rb +16 -41
  37. data/test/integration/lockable_test.rb +11 -14
  38. data/test/integration/recoverable_test.rb +23 -15
  39. data/test/mailers/confirmation_instructions_test.rb +6 -2
  40. data/test/mailers/reset_password_instructions_test.rb +6 -2
  41. data/test/mailers/unlock_instructions_test.rb +6 -2
  42. data/test/models/confirmable_test.rb +20 -30
  43. data/test/models/lockable_test.rb +15 -5
  44. data/test/models/recoverable_test.rb +20 -48
  45. data/test/models_test.rb +0 -19
  46. data/test/parameter_sanitizer_test.rb +23 -9
  47. data/test/rails_app/config/initializers/devise.rb +3 -0
  48. data/test/rails_app/lib/shared_admin.rb +3 -0
  49. data/test/rails_app/lib/shared_user.rb +4 -0
  50. data/test/support/helpers.rb +0 -21
  51. metadata +23 -7
  52. data/app/views/devise/_links.erb +0 -3
@@ -13,6 +13,7 @@ class LockTest < ActionDispatch::IntegrationTest
13
13
  visit new_user_session_path
14
14
  click_link "Didn't receive unlock instructions?"
15
15
 
16
+ Devise.stubs(:friendly_token).returns("abcdef")
16
17
  fill_in 'email', :with => user.email
17
18
  click_button 'Resend unlock instructions'
18
19
  end
@@ -22,8 +23,11 @@ class LockTest < ActionDispatch::IntegrationTest
22
23
 
23
24
  assert_template 'sessions/new'
24
25
  assert_contain 'You will receive an email with instructions about how to unlock your account in a few minutes'
26
+
27
+ mail = ActionMailer::Base.deliveries.last
25
28
  assert_equal 1, ActionMailer::Base.deliveries.size
26
- assert_equal ['please-change-me@config-initializers-devise.com'], ActionMailer::Base.deliveries.first.from
29
+ assert_equal ['please-change-me@config-initializers-devise.com'], mail.from
30
+ assert_match user_unlock_path(unlock_token: 'abcdef'), mail.body.encoded
27
31
  end
28
32
 
29
33
  test 'user should receive the instructions from a custom mailer' do
@@ -75,23 +79,15 @@ class LockTest < ActionDispatch::IntegrationTest
75
79
  end
76
80
 
77
81
  test "locked user should be able to unlock account" do
78
- user = create_user(:locked => true)
79
- assert user.access_locked?
80
-
81
- visit_user_unlock_with_token(user.unlock_token)
82
+ user = create_user
83
+ raw = user.lock_access!
84
+ visit_user_unlock_with_token(raw)
82
85
 
83
86
  assert_current_url "/users/sign_in"
84
87
  assert_contain 'Your account has been unlocked successfully. Please sign in to continue.'
85
-
86
88
  assert_not user.reload.access_locked?
87
89
  end
88
90
 
89
- test "redirect user to sign in page after unlocking its account" do
90
- user = create_user(:locked => true)
91
- visit_user_unlock_with_token(user.unlock_token)
92
- assert_not warden.authenticated?(:user)
93
- end
94
-
95
91
  test "user should not send a new e-mail if already locked" do
96
92
  user = create_user(:locked => true)
97
93
  user.failed_attempts = User.maximum_attempts + 1
@@ -153,9 +149,10 @@ class LockTest < ActionDispatch::IntegrationTest
153
149
  end
154
150
 
155
151
  test 'user with valid unlock token should be able to unlock account via XML request' do
156
- user = create_user(:locked => true)
152
+ user = create_user()
153
+ raw = user.lock_access!
157
154
  assert user.access_locked?
158
- get user_unlock_path(:format => 'xml', :unlock_token => user.unlock_token)
155
+ get user_unlock_path(:format => 'xml', :unlock_token => raw)
159
156
  assert_response :success
160
157
  assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
161
158
  end
@@ -14,12 +14,16 @@ class PasswordTest < ActionDispatch::IntegrationTest
14
14
 
15
15
  fill_in 'email', :with => 'user@test.com'
16
16
  yield if block_given?
17
+
18
+ Devise.stubs(:friendly_token).returns("abcdef")
17
19
  click_button 'Send me reset password instructions'
18
20
  end
19
21
 
20
22
  def reset_password(options={}, &block)
21
- visit edit_user_password_path(:reset_password_token => options[:reset_password_token]) unless options[:visit] == false
22
- assert_response :success
23
+ unless options[:visit] == false
24
+ visit edit_user_password_path(:reset_password_token => options[:reset_password_token] || "abcdef")
25
+ assert_response :success
26
+ end
23
27
 
24
28
  fill_in 'New password', :with => '987654321'
25
29
  fill_in 'Confirm new password', :with => '987654321'
@@ -45,7 +49,10 @@ class PasswordTest < ActionDispatch::IntegrationTest
45
49
  request_forgot_password do
46
50
  fill_in 'email', :with => 'foo@bar.com'
47
51
  end
48
- assert_equal ['custom@example.com'], ActionMailer::Base.deliveries.last.from
52
+
53
+ mail = ActionMailer::Base.deliveries.last
54
+ assert_equal ['custom@example.com'], mail.from
55
+ assert_match edit_user_password_path(reset_password_token: 'abcdef'), mail.body.encoded
49
56
  end
50
57
 
51
58
  test 'reset password with email of different case should fail when email is NOT the list of case insensitive keys' do
@@ -146,7 +153,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
146
153
  test 'not authenticated user with valid reset password token but invalid password should not be able to change his password' do
147
154
  user = create_user
148
155
  request_forgot_password
149
- reset_password :reset_password_token => user.reload.reset_password_token do
156
+ reset_password do
150
157
  fill_in 'Confirm new password', :with => 'other_password'
151
158
  end
152
159
 
@@ -161,7 +168,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
161
168
  test 'not authenticated user with valid data should be able to change his password' do
162
169
  user = create_user
163
170
  request_forgot_password
164
- reset_password :reset_password_token => user.reload.reset_password_token
171
+ reset_password
165
172
 
166
173
  assert_current_url '/'
167
174
  assert_contain 'Your password was changed successfully. You are now signed in.'
@@ -171,14 +178,13 @@ class PasswordTest < ActionDispatch::IntegrationTest
171
178
  test 'after entering invalid data user should still be able to change his password' do
172
179
  user = create_user
173
180
  request_forgot_password
174
- reset_password :reset_password_token => user.reload.reset_password_token do
175
- fill_in 'Confirm new password', :with => 'other_password'
176
- end
181
+
182
+ reset_password { fill_in 'Confirm new password', :with => 'other_password' }
177
183
  assert_response :success
178
184
  assert_have_selector '#error_explanation'
179
185
  assert_not user.reload.valid_password?('987654321')
180
186
 
181
- reset_password :reset_password_token => user.reload.reset_password_token, :visit => false
187
+ reset_password :visit => false
182
188
  assert_contain 'Your password was changed successfully.'
183
189
  assert user.reload.valid_password?('987654321')
184
190
  end
@@ -186,7 +192,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
186
192
  test 'sign in user automatically after changing its password' do
187
193
  user = create_user
188
194
  request_forgot_password
189
- reset_password :reset_password_token => user.reload.reset_password_token
195
+ reset_password
190
196
 
191
197
  assert warden.authenticated?(:user)
192
198
  end
@@ -196,7 +202,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
196
202
  swap Devise, :unlock_strategy => strategy do
197
203
  user = create_user(:locked => true)
198
204
  request_forgot_password
199
- reset_password :reset_password_token => user.reload.reset_password_token
205
+ reset_password
200
206
 
201
207
  assert_contain 'Your password was changed successfully.'
202
208
  assert_not_contain 'You are now signed in.'
@@ -210,7 +216,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
210
216
  swap Devise, :unlock_strategy => :email do
211
217
  user = create_user(:locked => true)
212
218
  request_forgot_password
213
- reset_password :reset_password_token => user.reload.reset_password_token
219
+ reset_password
214
220
 
215
221
  assert_contain 'Your password was changed successfully.'
216
222
  assert !user.reload.access_locked?
@@ -222,7 +228,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
222
228
  swap Devise, :unlock_strategy => :both do
223
229
  user = create_user(:locked => true)
224
230
  request_forgot_password
225
- reset_password :reset_password_token => user.reload.reset_password_token
231
+ reset_password
226
232
 
227
233
  assert_contain 'Your password was changed successfully.'
228
234
  assert !user.reload.access_locked?
@@ -256,7 +262,9 @@ class PasswordTest < ActionDispatch::IntegrationTest
256
262
  test 'change password with valid parameters in XML format should return valid response' do
257
263
  user = create_user
258
264
  request_forgot_password
259
- put user_password_path(:format => 'xml'), :user => {:reset_password_token => user.reload.reset_password_token, :password => '987654321', :password_confirmation => '987654321'}
265
+ put user_password_path(:format => 'xml'), :user => {
266
+ :reset_password_token => 'abcdef', :password => '987654321', :password_confirmation => '987654321'
267
+ }
260
268
  assert_response :success
261
269
  assert warden.authenticated?(:user)
262
270
  end
@@ -317,7 +325,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
317
325
 
318
326
  assert_equal 10, user.failed_attempts
319
327
  request_forgot_password
320
- reset_password :reset_password_token => user.reload.reset_password_token
328
+ reset_password
321
329
 
322
330
  assert warden.authenticated?(:user)
323
331
  user.reload
@@ -84,8 +84,12 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
84
84
 
85
85
  test 'body should have link to confirm the account' do
86
86
  host = ActionMailer::Base.default_url_options[:host]
87
- confirmation_url_regexp = %r{<a href=\"http://#{host}/users/confirmation\?confirmation_token=#{user.confirmation_token}">}
88
- assert_match confirmation_url_regexp, mail.body.encoded
87
+
88
+ if mail.body.encoded =~ %r{<a href=\"http://#{host}/users/confirmation\?confirmation_token=([^"]+)">}
89
+ assert_equal Devise.token_generator.digest(user.class, :confirmation_token, $1), user.confirmation_token
90
+ else
91
+ flunk "expected confirmation url regex to match"
92
+ end
89
93
  end
90
94
 
91
95
  test 'renders a scoped if scoped_views is set to true' do
@@ -80,8 +80,12 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
80
80
 
81
81
  test 'body should have link to confirm the account' do
82
82
  host = ActionMailer::Base.default_url_options[:host]
83
- reset_url_regexp = %r{<a href=\"http://#{host}/users/password/edit\?reset_password_token=#{user.reset_password_token}">}
84
- assert_match reset_url_regexp, mail.body.encoded
83
+
84
+ if mail.body.encoded =~ %r{<a href=\"http://#{host}/users/password/edit\?reset_password_token=([^"]+)">}
85
+ assert_equal Devise.token_generator.digest(user.class, :reset_password_token, $1), user.reset_password_token
86
+ else
87
+ flunk "expected reset password url regex to match"
88
+ end
85
89
  end
86
90
 
87
91
  test 'mailer sender accepts a proc' do
@@ -81,7 +81,11 @@ class UnlockInstructionsTest < ActionMailer::TestCase
81
81
 
82
82
  test 'body should have link to unlock the account' do
83
83
  host = ActionMailer::Base.default_url_options[:host]
84
- unlock_url_regexp = %r{<a href=\"http://#{host}/users/unlock\?unlock_token=#{user.unlock_token}">}
85
- assert_match unlock_url_regexp, mail.body.encoded
84
+
85
+ if mail.body.encoded =~ %r{<a href=\"http://#{host}/users/unlock\?unlock_token=([^"]+)">}
86
+ assert_equal Devise.token_generator.digest(user.class, :unlock_token, $1), user.unlock_token
87
+ else
88
+ flunk "expected unlock url regex to match"
89
+ end
86
90
  end
87
91
  end
@@ -51,9 +51,19 @@ class ConfirmableTest < ActiveSupport::TestCase
51
51
  assert_equal "was already confirmed, please try signing in", user.errors[:email].join
52
52
  end
53
53
 
54
- test 'should find and confirm a user automatically' do
54
+ test 'DEPRECATED: should find and confirm a user automatically' do
55
+ swap Devise, allow_insecure_token_lookup: true do
56
+ user = create_user
57
+ confirmed_user = User.confirm_by_token(user.confirmation_token)
58
+ assert_equal confirmed_user, user
59
+ assert user.reload.confirmed?
60
+ end
61
+ end
62
+
63
+ test 'should find and confirm a user automatically based on the raw token' do
55
64
  user = create_user
56
- confirmed_user = User.confirm_by_token(user.confirmation_token)
65
+ raw = user.raw_confirmation_token
66
+ confirmed_user = User.confirm_by_token(raw)
57
67
  assert_equal confirmed_user, user
58
68
  assert user.reload.confirmed?
59
69
  end
@@ -74,7 +84,7 @@ class ConfirmableTest < ActiveSupport::TestCase
74
84
  user = create_user
75
85
  user.confirmed_at = Time.now
76
86
  user.save
77
- confirmed_user = User.confirm_by_token(user.confirmation_token)
87
+ confirmed_user = User.confirm_by_token(user.raw_confirmation_token)
78
88
  assert confirmed_user.confirmed?
79
89
  assert_equal "was already confirmed, please try signing in", confirmed_user.errors[:email].join
80
90
  end
@@ -176,7 +186,7 @@ class ConfirmableTest < ActiveSupport::TestCase
176
186
  test 'should not be able to send instructions if the user is already confirmed' do
177
187
  user = create_user
178
188
  user.confirm!
179
- assert_not user.resend_confirmation_token
189
+ assert_not user.resend_confirmation_instructions
180
190
  assert user.confirmed?
181
191
  assert_equal 'was already confirmed, please try signing in', user.errors[:email].join
182
192
  end
@@ -264,7 +274,7 @@ class ConfirmableTest < ActiveSupport::TestCase
264
274
  def confirm_user_by_token_with_confirmation_sent_at(confirmation_sent_at)
265
275
  user = create_user
266
276
  user.update_attribute(:confirmation_sent_at, confirmation_sent_at)
267
- confirmed_user = User.confirm_by_token(user.confirmation_token)
277
+ confirmed_user = User.confirm_by_token(user.raw_confirmation_token)
268
278
  assert_equal confirmed_user, user
269
279
  user.reload.confirmed?
270
280
  end
@@ -285,32 +295,12 @@ class ConfirmableTest < ActiveSupport::TestCase
285
295
  end
286
296
  end
287
297
 
288
- test 'should generate a new token if the previous one has expired' do
289
- swap Devise, :confirm_within => 3.days do
290
- user = create_user
291
- user.update_attribute(:confirmation_sent_at, 4.days.ago)
292
- old = user.confirmation_token
293
- user.resend_confirmation_token
294
- assert_not_equal user.confirmation_token, old
295
- end
296
- end
297
-
298
- test 'should generate a new token when a valid one does not exist' do
299
- swap Devise, :confirm_within => 3.days do
300
- user = create_user
301
- user.update_attribute(:confirmation_sent_at, 4.days.ago)
302
- old = user.confirmation_token
303
- user.ensure_confirmation_token!
304
- assert_not_equal user.confirmation_token, old
305
- end
306
- end
307
-
308
- test 'should not generate a new token when a valid one exists' do
298
+ test 'always generate a new token on resend' do
309
299
  user = create_user
310
- assert_not_nil user.confirmation_token
311
- old = user.confirmation_token
312
- user.ensure_confirmation_token!
313
- assert_equal user.confirmation_token, old
300
+ old = user.confirmation_token
301
+ user = User.find(user.id)
302
+ user.resend_confirmation_instructions
303
+ assert_not_equal user.confirmation_token, old
314
304
  end
315
305
 
316
306
  test 'should call after_confirmation if confirmed' do
@@ -139,10 +139,20 @@ class LockableTest < ActiveSupport::TestCase
139
139
  end
140
140
  end
141
141
 
142
- test 'should find and unlock a user automatically' do
142
+ test 'DEPRECATED: should find and unlock a user automatically' do
143
+ swap Devise, allow_insecure_token_lookup: true do
144
+ user = create_user
145
+ user.lock_access!
146
+ locked_user = User.unlock_access_by_token(user.unlock_token)
147
+ assert_equal locked_user, user
148
+ assert_not user.reload.access_locked?
149
+ end
150
+ end
151
+
152
+ test 'should find and unlock a user automatically based on raw token' do
143
153
  user = create_user
144
- user.lock_access!
145
- locked_user = User.unlock_access_by_token(user.unlock_token)
154
+ raw = user.send_unlock_instructions
155
+ locked_user = User.unlock_access_by_token(raw)
146
156
  assert_equal locked_user, user
147
157
  assert_not user.reload.access_locked?
148
158
  end
@@ -195,7 +205,7 @@ class LockableTest < ActiveSupport::TestCase
195
205
 
196
206
  test 'should not be able to send instructions if the user is not locked' do
197
207
  user = create_user
198
- assert_not user.resend_unlock_token
208
+ assert_not user.resend_unlock_instructions
199
209
  assert_not user.access_locked?
200
210
  assert_equal 'was not locked', user.errors[:email].join
201
211
  end
@@ -203,7 +213,7 @@ class LockableTest < ActiveSupport::TestCase
203
213
  test 'should not be able to send instructions if the user if not locked and have username as unlock key' do
204
214
  swap Devise, :unlock_keys => [:username] do
205
215
  user = create_user
206
- assert_not user.resend_unlock_token
216
+ assert_not user.resend_unlock_instructions
207
217
  assert_not user.access_locked?
208
218
  assert_equal 'was not locked', user.errors[:username].join
209
219
  end
@@ -108,11 +108,21 @@ class RecoverableTest < ActiveSupport::TestCase
108
108
  end
109
109
  end
110
110
 
111
- test 'should find a user to reset his password based on reset_password_token' do
111
+ test 'DEPRECATED: should find a user to reset his password based on reset_password_token' do
112
+ swap Devise, allow_insecure_token_lookup: true do
113
+ user = create_user
114
+ user.send_reset_password_instructions
115
+
116
+ reset_password_user = User.reset_password_by_token(:reset_password_token => user.reset_password_token)
117
+ assert_equal reset_password_user, user
118
+ end
119
+ end
120
+
121
+ test 'should find a user to reset his password based on the raw token' do
112
122
  user = create_user
113
- user.ensure_reset_password_token!
123
+ raw = user.send_reset_password_instructions
114
124
 
115
- reset_password_user = User.reset_password_by_token(:reset_password_token => user.reset_password_token)
125
+ reset_password_user = User.reset_password_by_token(:reset_password_token => raw)
116
126
  assert_equal reset_password_user, user
117
127
  end
118
128
 
@@ -130,9 +140,9 @@ class RecoverableTest < ActiveSupport::TestCase
130
140
 
131
141
  test 'should return a new record with errors if password is blank' do
132
142
  user = create_user
133
- user.ensure_reset_password_token!
143
+ raw = user.send_reset_password_instructions
134
144
 
135
- reset_password_user = User.reset_password_by_token(:reset_password_token => user.reset_password_token, :password => '')
145
+ reset_password_user = User.reset_password_by_token(:reset_password_token => raw, :password => '')
136
146
  assert_not reset_password_user.errors.empty?
137
147
  assert_match "can't be blank", reset_password_user.errors[:password].join
138
148
  end
@@ -140,10 +150,10 @@ class RecoverableTest < ActiveSupport::TestCase
140
150
  test 'should reset successfully user password given the new password and confirmation' do
141
151
  user = create_user
142
152
  old_password = user.password
143
- user.ensure_reset_password_token!
153
+ raw = user.send_reset_password_instructions
144
154
 
145
155
  User.reset_password_by_token(
146
- :reset_password_token => user.reset_password_token,
156
+ :reset_password_token => raw,
147
157
  :password => 'new_password',
148
158
  :password_confirmation => 'new_password'
149
159
  )
@@ -153,38 +163,17 @@ class RecoverableTest < ActiveSupport::TestCase
153
163
  assert user.valid_password?('new_password')
154
164
  end
155
165
 
156
- test 'should not reset reset password token during reset_password_within time' do
157
- swap Devise, :reset_password_within => 1.hour do
158
- user = create_user
159
- user.send_reset_password_instructions
160
- 3.times do
161
- token = user.reset_password_token
162
- user.send_reset_password_instructions
163
- assert_equal token, user.reset_password_token
164
- end
165
- end
166
- end
167
-
168
- test 'should reset reset password token after reset_password_within time' do
169
- swap Devise, :reset_password_within => 1.hour do
170
- user = create_user
171
- user.reset_password_sent_at = 2.days.ago
172
- token = user.reset_password_token
173
- user.send_reset_password_instructions
174
- assert_not_equal token, user.reset_password_token
175
- end
176
- end
177
-
178
166
  test 'should not reset password after reset_password_within time' do
179
167
  swap Devise, :reset_password_within => 1.hour do
180
168
  user = create_user
169
+ raw = user.send_reset_password_instructions
170
+
181
171
  old_password = user.password
182
- user.ensure_reset_password_token!
183
172
  user.reset_password_sent_at = 2.days.ago
184
173
  user.save!
185
174
 
186
175
  reset_password_user = User.reset_password_by_token(
187
- :reset_password_token => user.reset_password_token,
176
+ :reset_password_token => raw,
188
177
  :password => 'new_password',
189
178
  :password_confirmation => 'new_password'
190
179
  )
@@ -201,22 +190,5 @@ class RecoverableTest < ActiveSupport::TestCase
201
190
  :reset_password_sent_at,
202
191
  :reset_password_token
203
192
  ]
204
- end
205
-
206
- test 'should generate a new token when a valid one does not exist' do
207
- user = create_user
208
- assert_nil user.reset_password_token
209
-
210
- user.ensure_reset_password_token!
211
- assert_not_nil user.reset_password_token
212
- end
213
-
214
- test 'should not generate a new token when a valid one exists' do
215
- user = create_user
216
- user.send :generate_reset_password_token!
217
- assert_not_nil user.reset_password_token
218
- old = user.reset_password_token
219
- user.ensure_reset_password_token!
220
- assert_equal user.reset_password_token, old
221
193
  end
222
194
  end