2010-03-26 06:27:19 -04:00
|
|
|
require 'test_helper'
|
2009-11-22 19:19:29 -05:00
|
|
|
|
|
|
|
class TimeoutableTest < ActiveSupport::TestCase
|
|
|
|
|
2009-11-22 19:33:19 -05:00
|
|
|
test 'should be expired' do
|
2010-01-14 09:47:14 -05:00
|
|
|
assert new_user.timedout?(31.minutes.ago)
|
2009-11-22 19:33:19 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'should not be expired' do
|
2010-01-14 09:47:14 -05:00
|
|
|
assert_not new_user.timedout?(29.minutes.ago)
|
2009-11-22 19:33:19 -05:00
|
|
|
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)
|
2009-11-22 19:33:19 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'fallback to Devise config option' do
|
2009-11-24 21:11:49 -05:00
|
|
|
swap Devise, :timeout_in => 1.minute do
|
2009-11-22 19:33:19 -05:00
|
|
|
user = new_user
|
2010-01-14 09:47:14 -05:00
|
|
|
assert user.timedout?(2.minutes.ago)
|
|
|
|
assert_not user.timedout?(30.seconds.ago)
|
2009-11-24 20:19:12 -05:00
|
|
|
|
2009-11-24 21:11:49 -05:00
|
|
|
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)
|
2009-11-22 19:33:19 -05:00
|
|
|
end
|
|
|
|
end
|
2009-11-22 19:19:29 -05:00
|
|
|
end
|