1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00
heartcombo--devise/test/models/timeoutable_test.rb

29 lines
697 B
Ruby
Raw Normal View History

require 'test/test_helper'
class TimeoutableTest < ActiveSupport::TestCase
test 'should be expired' do
2010-01-14 09:47:14 -05:00
assert new_user.timedout?(31.minutes.ago)
end
test 'should not be expired' do
2010-01-14 09:47:14 -05:00
assert_not new_user.timedout?(29.minutes.ago)
end
test 'should not be expired when params is nil' do
2010-01-14 09:47:14 -05:00
assert_not new_user.timedout?(nil)
end
test 'fallback to Devise config option' do
swap Devise, :timeout_in => 1.minute do
user = new_user
2010-01-14 09:47:14 -05:00
assert user.timedout?(2.minutes.ago)
assert_not user.timedout?(30.seconds.ago)
Devise.timeout_in = 5.minutes
2010-01-14 09:47:14 -05:00
assert_not user.timedout?(2.minutes.ago)
assert user.timedout?(6.minutes.ago)
end
end
end