Compare commits

...

12 Commits

Author SHA1 Message Date
Ulisses Almeida
4da955d9cd Release 4.0.1 2016-04-25 17:06:05 -03:00
Ulisses Almeida
bff701758a Merge pull request #4043 from lmduc/master
Send confirmation instructions when a user updates the email address from nil
2016-04-25 16:42:55 -03:00
Ulisses Almeida
90acc6fc23 Change the check for permit! method
We are using the `permit!` method, we should check
for `permit!`.
2016-04-22 20:36:55 -03:00
Ulisses Almeida
48220f087b Merge pull request #4050 from cadejscroggins/master
Make sure attribute_will_change! method exists before calling it
2016-04-20 23:10:25 -03:00
Cade Scroggins
26b17abb01 Remove attribute_will_change! method as it is unnecessary 2016-04-20 20:23:03 -05:00
Lucas Mazza
22468f3756 Merge pull request #3855 from joshsoftware/mongoid_dep
Upgrade Mongoid to 5.0
2016-04-19 10:14:26 -03:00
Yogesh Khater
9696d83e7d Upgrade Mongoid to 5.0 2016-04-19 17:18:40 +05:30
MatBi
7d10019d2a Should check email present 2016-04-18 19:52:31 +08:00
MatBi
274f8f2f87 Should send confirmation instructions after changing email from nil 2016-04-18 19:35:56 +08:00
MatBi
3360b10c2f Skip reconfirmation in case that a record is created with #save called in callback 2016-04-18 19:32:54 +08:00
MatBi
6f9561e64f Refactor a test 2016-04-18 18:30:20 +08:00
MatBi
016b216d95 Change the name of variables to keep the tests consistent 2016-04-18 18:15:32 +08:00
9 changed files with 35 additions and 23 deletions

View File

@@ -1,5 +1,13 @@
### Unreleased
### 4.0.1 - 2016-04-25
* bug fixes
* Fix the e-mail confirmation instructions send when a user updates the email
address from nil. (by @lmduc)
* Remove unnecessary `attribute_will_change!` call. (by @cadejscroggins)
* Consistent `permit!` check. (by @ulissesalmeida)
### 4.0.0 - 2016-04-18
* bug fixes

View File

@@ -25,5 +25,5 @@ platforms :ruby do
end
group :mongoid do
gem "mongoid", "~> 4.0"
gem "mongoid", "~> 5.0"
end

View File

@@ -1,7 +1,7 @@
PATH
remote: .
specs:
devise (4.0.0)
devise (4.0.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.1)
@@ -48,10 +48,9 @@ GEM
tzinfo (~> 1.1)
arel (6.0.3)
bcrypt (3.1.11)
bson (3.2.6)
bson (4.0.0)
builder (3.2.2)
concurrent-ruby (1.0.1)
connection_pool (2.2.0)
erubis (2.7.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
@@ -71,15 +70,13 @@ GEM
minitest (5.8.4)
mocha (1.1.0)
metaclass (~> 0.0.1)
mongoid (4.0.2)
mongo (2.2.0)
bson (~> 4.0)
mongoid (5.0.1)
activemodel (~> 4.0)
moped (~> 2.0.0)
mongo (~> 2.1)
origin (~> 2.1)
tzinfo (>= 0.3.37)
moped (2.0.7)
bson (~> 3.0)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.11.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
@@ -102,7 +99,6 @@ GEM
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
optionable (0.2.0)
origin (2.2.0)
orm_adapter (0.5.0)
rack (1.6.4)
@@ -169,7 +165,7 @@ DEPENDENCIES
devise!
jruby-openssl
mocha (~> 1.1)
mongoid (~> 4.0)
mongoid (~> 5.0)
omniauth (~> 1.3)
omniauth-facebook
omniauth-oauth2 (~> 1.4)

View File

@@ -253,7 +253,7 @@ module Devise
# Find or initialize a record with group of attributes based on a list of required attributes.
def find_or_initialize_with_errors(required_attributes, attributes, error=:invalid) #:nodoc:
attributes = if attributes.respond_to? :permit
attributes = if attributes.respond_to? :permit!
attributes.slice(*required_attributes).permit!.to_h.with_indifferent_access
else
attributes.with_indifferent_access.slice(*required_attributes)

View File

@@ -169,6 +169,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.
@@ -253,13 +254,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

@@ -41,7 +41,6 @@ module Devise
# For legacy reasons, we use `encrypted_password` to store
# the hashed password.
def password=(new_password)
attribute_will_change! 'password'
@password = new_password
self.encrypted_password = password_digest(@password) if @password.present?
end

View File

@@ -1,3 +1,3 @@
module Devise
VERSION = "4.0.0".freeze
VERSION = "4.0.1".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

View File

@@ -1,5 +1,5 @@
test:
sessions:
<%= Mongoid::VERSION.to_i > 4 ? 'clients' : 'sessions' %>:
default:
database: devise-test-suite
hosts: