Skip to content

Commit 941630e

Browse files
fixup! test: add unit tests for two-factor model, strategy, and registration
1 parent 43be3c2 commit 941630e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/strategies/two_factor_test.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@ class TwoFactorStrategyTest < ActiveSupport::TestCase
77
assert defined?(Devise::Strategies::TwoFactor)
88
end
99

10-
test 'TwoFactor base strategy is never valid' do
11-
strategy = Devise::Strategies::TwoFactor.new(nil)
12-
assert_equal false, strategy.valid?
10+
test 'TwoFactor base strategy is not valid without a pending session' do
11+
strategy = Devise::Strategies::TwoFactor.new(env_with_session)
12+
assert_not strategy.valid?
1313
end
1414

1515
test 'verify_two_factor! raises NotImplementedError by default' do
16-
strategy = Devise::Strategies::TwoFactor.new(nil)
16+
strategy = Devise::Strategies::TwoFactor.new(env_with_session)
1717
assert_raises(NotImplementedError) do
1818
strategy.verify_two_factor!(Object.new)
1919
end
2020
end
21+
22+
private
23+
24+
def env_with_session(session = {})
25+
{ 'rack.session' => session }
26+
end
2127
end

0 commit comments

Comments
 (0)