Automatically create the confirmation_token when email is sent for optionally confirmable models
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
02c2df65cd
commit
592fa59e88
|
@ -50,6 +50,7 @@ module Devise
|
|||
|
||||
# Send confirmation instructions by email
|
||||
def send_confirmation_instructions
|
||||
generate_confirmation_token if self.confirmation_token.nil?
|
||||
::Devise::Mailer.confirmation_instructions(self).deliver
|
||||
end
|
||||
|
||||
|
|
|
@ -128,6 +128,14 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
test 'should always have confirmation token when email is sent' do
|
||||
user = new_user
|
||||
user.instance_eval { def confirmation_required?; false end }
|
||||
user.save
|
||||
user.send_confirmation_instructions
|
||||
assert_not_nil user.confirmation_token
|
||||
end
|
||||
|
||||
test 'should not resend email instructions if the user change his email' do
|
||||
user = create_user
|
||||
user.email = 'new_test@example.com'
|
||||
|
|
Loading…
Reference in New Issue