Send confirmation instructions only works if the record is not confirmed.
This commit is contained in:
parent
417f273a81
commit
e8611609ac
|
@ -59,9 +59,11 @@ module Devise
|
|||
# confirming it's account
|
||||
#
|
||||
def reset_confirmation!
|
||||
reset_confirmation
|
||||
reset_perishable_token!
|
||||
send_confirmation_instructions
|
||||
unless_confirmed do
|
||||
reset_confirmation
|
||||
reset_perishable_token!
|
||||
send_confirmation_instructions
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'test/test_helper'
|
|||
class UsersConfirmationTest < ActionController::IntegrationTest
|
||||
|
||||
test 'user should be able to request a new confirmation' do
|
||||
user = create_user
|
||||
user = create_user(:confirm => false)
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
visit new_user_session_path
|
||||
|
|
|
@ -112,8 +112,6 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|||
test 'should reset confirmation status when sending the confirmation instructions' do
|
||||
user = create_user
|
||||
assert_not user.confirmed?
|
||||
user.confirm!
|
||||
assert user.confirmed?
|
||||
confirmation_user = User.send_confirmation_instructions(:email => user.email)
|
||||
assert_not user.reload.confirmed?
|
||||
end
|
||||
|
@ -150,4 +148,13 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|||
user.save!
|
||||
assert_not user.reload.confirmed?
|
||||
end
|
||||
|
||||
test 'should not be able to send instructions if the user is already confirmed' do
|
||||
user = create_user
|
||||
user.confirm!
|
||||
assert_not user.reset_confirmation!
|
||||
assert user.confirmed?
|
||||
assert user.errors[:email].present?
|
||||
assert_equal 'already confirmed', user.errors[:email]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue