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
|
# confirming it's account
|
||||||
#
|
#
|
||||||
def reset_confirmation!
|
def reset_confirmation!
|
||||||
reset_confirmation
|
unless_confirmed do
|
||||||
reset_perishable_token!
|
reset_confirmation
|
||||||
send_confirmation_instructions
|
reset_perishable_token!
|
||||||
|
send_confirmation_instructions
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'test/test_helper'
|
||||||
class UsersConfirmationTest < ActionController::IntegrationTest
|
class UsersConfirmationTest < ActionController::IntegrationTest
|
||||||
|
|
||||||
test 'user should be able to request a new confirmation' do
|
test 'user should be able to request a new confirmation' do
|
||||||
user = create_user
|
user = create_user(:confirm => false)
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
|
|
||||||
visit new_user_session_path
|
visit new_user_session_path
|
||||||
|
|
|
@ -112,8 +112,6 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||||
test 'should reset confirmation status when sending the confirmation instructions' do
|
test 'should reset confirmation status when sending the confirmation instructions' do
|
||||||
user = create_user
|
user = create_user
|
||||||
assert_not user.confirmed?
|
assert_not user.confirmed?
|
||||||
user.confirm!
|
|
||||||
assert user.confirmed?
|
|
||||||
confirmation_user = User.send_confirmation_instructions(:email => user.email)
|
confirmation_user = User.send_confirmation_instructions(:email => user.email)
|
||||||
assert_not user.reload.confirmed?
|
assert_not user.reload.confirmed?
|
||||||
end
|
end
|
||||||
|
@ -150,4 +148,13 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||||
user.save!
|
user.save!
|
||||||
assert_not user.reload.confirmed?
|
assert_not user.reload.confirmed?
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue