diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-04-15 15:44:51 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-04-15 15:44:51 +0000 |
commit | c7149f418408c0ad0b3b303469427ec9b1f2fae4 (patch) | |
tree | 035ca3d9765979d59619e69192a96471b5dc3e9e /test/unit/token_test.rb | |
parent | 24c361eb0a122e4a86621879539a067cea068a12 (diff) | |
download | redmine-c7149f418408c0ad0b3b303469427ec9b1f2fae4.tar.gz redmine-c7149f418408c0ad0b3b303469427ec9b1f2fae4.zip |
Fixed that Token.destroy_expired destroys API tokens.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9420 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/token_test.rb')
-rw-r--r-- | test/unit/token_test.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/unit/token_test.rb b/test/unit/token_test.rb index 54c1cc9c8..fca97f630 100644 --- a/test/unit/token_test.rb +++ b/test/unit/token_test.rb @@ -35,4 +35,27 @@ class TokenTest < ActiveSupport::TestCase assert !Token.exists?(t1.id) assert Token.exists?(t2.id) end + + def test_destroy_expired_should_not_destroy_feeds_and_api_tokens + Token.delete_all + + Token.create!(:user_id => 1, :action => 'api', :created_on => 7.days.ago) + Token.create!(:user_id => 1, :action => 'feeds', :created_on => 7.days.ago) + + assert_no_difference 'Token.count' do + assert_equal 0, Token.destroy_expired + end + end + + def test_destroy_expired_should_destroy_expired_tokens + Token.delete_all + + Token.create!(:user_id => 1, :action => 'autologin', :created_on => 7.days.ago) + Token.create!(:user_id => 2, :action => 'autologin', :created_on => 3.days.ago) + Token.create!(:user_id => 3, :action => 'autologin', :created_on => 1.hour.ago) + + assert_difference 'Token.count', -2 do + assert_equal 2, Token.destroy_expired + end + end end |