Compare commits

...

2 Commits

Author SHA1 Message Date
Ulisses Almeida
b8cddc3cf3 Release 3.5.8 2016-04-25 16:57:28 -03:00
MatBi
1d57169c7b Send confirmation instructions when a user updates the email address from nil 2016-04-25 16:51:40 -03:00
5 changed files with 23 additions and 9 deletions

View File

@@ -1,5 +1,10 @@
### Unreleased
### 3.5.8 - 2016-04-25
* bug fixes
* Fix the e-mail confirmation instructions send when a user updates the email address from nil
### 3.5.7 - 2016-04-18
* bug fixes

View File

@@ -1,7 +1,7 @@
PATH
remote: .
specs:
devise (3.5.7)
devise (3.5.8)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)

View File

@@ -170,6 +170,7 @@ module Devise
# in models to map to a nice sign up e-mail.
def send_on_create_confirmation_instructions
send_confirmation_instructions
skip_reconfirmation!
end
# Callback to overwrite if confirmation is required or not.
@@ -254,13 +255,13 @@ module Devise
end
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
postpone
end
def reconfirmation_required?
self.class.reconfirmable && @reconfirmation_required && self.email.present?
self.class.reconfirmable && @reconfirmation_required && (self.email.present? || self.unconfirmed_email.present?)
end
def send_confirmation_notification?

View File

@@ -1,3 +1,3 @@
module Devise
VERSION = "3.5.7".freeze
VERSION = "3.5.8".freeze
end

View File

@@ -114,7 +114,7 @@ class ConfirmableTest < ActiveSupport::TestCase
assert_email_not_sent do
user.save!
assert !user.confirmed?
assert_not user.confirmed?
end
end
@@ -401,6 +401,14 @@ class ReconfirmableTest < ActiveSupport::TestCase
assert_match "new_test@example.com", ActionMailer::Base.deliveries.last.body.encoded
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
admin = create_admin
assert admin.confirm
@@ -488,8 +496,8 @@ class ReconfirmableTest < ActiveSupport::TestCase
end
test 'should not require reconfirmation after creating a record' do
user = create_admin
assert !user.pending_reconfirmation?
admin = create_admin
assert !admin.pending_reconfirmation?
end
test 'should not require reconfirmation after creating a record with #save called in callback' do
@@ -497,7 +505,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
after_create :save
end
user = Admin::WithSaveInCallback.create(valid_attributes.except(:username))
assert !user.pending_reconfirmation?
admin = Admin::WithSaveInCallback.create(valid_attributes.except(:username))
assert !admin.pending_reconfirmation?
end
end