From 02c2df65cd113e849aae7b24ab1f7e3f50e3cda4 Mon Sep 17 00:00:00 2001 From: Paul Rosania Date: Wed, 5 May 2010 16:31:11 -0500 Subject: [PATCH] Mark confirmable roles as active when confirmation_required? is false MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- lib/devise/models/confirmable.rb | 2 +- test/models/confirmable_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/devise/models/confirmable.rb b/lib/devise/models/confirmable.rb index 4a1ebc0d..df774213 100644 --- a/lib/devise/models/confirmable.rb +++ b/lib/devise/models/confirmable.rb @@ -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. diff --git a/test/models/confirmable_test.rb b/test/models/confirmable_test.rb index 27243a2d..94f8e618 100644 --- a/test/models/confirmable_test.rb +++ b/test/models/confirmable_test.rb @@ -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