mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-10 07:18:14 -05:00
Merge pull request #4076 from f3ndot/issue-4072-unlock-strategy-enabled-bug
Fix strategy checking in #unlock_strategy_enabled? for :none and undefined strategies
This commit is contained in:
@@ -325,4 +325,26 @@ class LockableTest < ActiveSupport::TestCase
|
||||
user.lock_access!
|
||||
assert_equal :locked, user.unauthenticated_message
|
||||
end
|
||||
|
||||
test 'unlock_strategy_enabled? should return true for both, email, and time strategies if :both is used' do
|
||||
swap Devise, unlock_strategy: :both do
|
||||
user = create_user
|
||||
assert_equal true, user.unlock_strategy_enabled?(:both)
|
||||
assert_equal true, user.unlock_strategy_enabled?(:time)
|
||||
assert_equal true, user.unlock_strategy_enabled?(:email)
|
||||
assert_equal false, user.unlock_strategy_enabled?(:none)
|
||||
assert_equal false, user.unlock_strategy_enabled?(:an_undefined_strategy)
|
||||
end
|
||||
end
|
||||
|
||||
test 'unlock_strategy_enabled? should return true only for the configured strategy' do
|
||||
swap Devise, unlock_strategy: :email do
|
||||
user = create_user
|
||||
assert_equal false, user.unlock_strategy_enabled?(:both)
|
||||
assert_equal false, user.unlock_strategy_enabled?(:time)
|
||||
assert_equal true, user.unlock_strategy_enabled?(:email)
|
||||
assert_equal false, user.unlock_strategy_enabled?(:none)
|
||||
assert_equal false, user.unlock_strategy_enabled?(:an_undefined_strategy)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user