Mark confirmable roles as active when confirmation_required? is false
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
59bee679ca
commit
02c2df65cd
|
@ -63,7 +63,7 @@ module Devise
|
|||
# is already confirmed, it should never be blocked. Otherwise we need to
|
||||
# calculate if the confirm time has not expired for this user.
|
||||
def active?
|
||||
super && (confirmed? || confirmation_period_valid?)
|
||||
super && (!confirmation_required? || confirmed? || confirmation_period_valid?)
|
||||
end
|
||||
|
||||
# The message to be shown if the account is inactive.
|
||||
|
|
|
@ -202,4 +202,12 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|||
user.save
|
||||
assert_not user.reload.active?
|
||||
end
|
||||
|
||||
test 'should be active without confirmation when confirmation is not required' do
|
||||
user = create_user
|
||||
user.instance_eval { def confirmation_required?; false end }
|
||||
user.confirmation_sent_at = nil
|
||||
user.save
|
||||
assert user.reload.active?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue