mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Should send confirmation instructions after changing email from nil
This commit is contained in:
parent
3360b10c2f
commit
274f8f2f87
2 changed files with 10 additions and 2 deletions
|
@ -254,13 +254,13 @@ module Devise
|
||||||
end
|
end
|
||||||
|
|
||||||
def postpone_email_change?
|
def postpone_email_change?
|
||||||
postpone = self.class.reconfirmable && email_changed? && email_was.present? && !@bypass_confirmation_postpone && self.email.present?
|
postpone = self.class.reconfirmable && email_changed? && !@bypass_confirmation_postpone && self.email.present?
|
||||||
@bypass_confirmation_postpone = false
|
@bypass_confirmation_postpone = false
|
||||||
postpone
|
postpone
|
||||||
end
|
end
|
||||||
|
|
||||||
def reconfirmation_required?
|
def reconfirmation_required?
|
||||||
self.class.reconfirmable && @reconfirmation_required && self.email.present?
|
self.class.reconfirmable && @reconfirmation_required && (self.email || self.unconfirmed_email)
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_confirmation_notification?
|
def send_confirmation_notification?
|
||||||
|
|
|
@ -401,6 +401,14 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||||
assert_match "new_test@example.com", ActionMailer::Base.deliveries.last.body.encoded
|
assert_match "new_test@example.com", ActionMailer::Base.deliveries.last.body.encoded
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'should send confirmation instructions by email after changing email from nil' do
|
||||||
|
admin = create_admin(email: nil)
|
||||||
|
assert_email_sent "new_test@example.com" do
|
||||||
|
assert admin.update_attributes(email: 'new_test@example.com')
|
||||||
|
end
|
||||||
|
assert_match "new_test@example.com", ActionMailer::Base.deliveries.last.body.encoded
|
||||||
|
end
|
||||||
|
|
||||||
test 'should not send confirmation by email after changing password' do
|
test 'should not send confirmation by email after changing password' do
|
||||||
admin = create_admin
|
admin = create_admin
|
||||||
assert admin.confirm
|
assert admin.confirm
|
||||||
|
|
Loading…
Reference in a new issue