2009-11-22 19:19:29 -05:00
|
|
|
require 'test/test_helper'
|
|
|
|
|
|
|
|
class TimeoutableTest < ActiveSupport::TestCase
|
|
|
|
|
2009-11-22 19:33:19 -05:00
|
|
|
test 'should be expired' do
|
2009-11-24 08:00:35 -05:00
|
|
|
assert new_user.timeout?(31.minutes.ago)
|
2009-11-22 19:33:19 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'should not be expired' do
|
2009-11-24 08:00:35 -05:00
|
|
|
assert_not new_user.timeout?(29.minutes.ago)
|
2009-11-22 19:33:19 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'should not be expired when params is nil' do
|
|
|
|
assert_not new_user.timeout?(nil)
|
|
|
|
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
|
|
|
|
assert user.timeout?(2.minutes.ago)
|
|
|
|
assert_not user.timeout?(30.seconds.ago)
|
2009-11-24 20:19:12 -05:00
|
|
|
|
2009-11-24 21:11:49 -05:00
|
|
|
Devise.timeout_in = 5.minutes
|
2009-11-22 19:33:19 -05:00
|
|
|
assert_not user.timeout?(2.minutes.ago)
|
|
|
|
assert user.timeout?(6.minutes.ago)
|
|
|
|
end
|
|
|
|
end
|
2009-11-22 19:19:29 -05:00
|
|
|
end
|