summaryrefslogtreecommitdiff
path: root/users/test
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-11-07 23:27:27 +0100
committerAzul <azul@leap.se>2013-11-08 09:45:09 +0100
commite2c0962077cf759b23639276cca42606ea2135ec (patch)
treea4a5faae5f26aefe0ae390c5ea01c94511631663 /users/test
parentd4f835662fac2d9dca705b5cba2e207562dec833 (diff)
Token.destroy_all_expired to cleanup expired tokens (#4411)
Diffstat (limited to 'users/test')
-rw-r--r--users/test/unit/token_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/users/test/unit/token_test.rb b/users/test/unit/token_test.rb
index f56c576..445a20c 100644
--- a/users/test/unit/token_test.rb
+++ b/users/test/unit/token_test.rb
@@ -61,6 +61,21 @@ class ClientCertificateTest < ActiveSupport::TestCase
end
end
+ test "Token.destroy_all_expired cleans up expired tokens only" do
+ expired = Token.new(user_id: @user.id)
+ expired.last_seen_at = 2.hours.ago
+ expired.save
+ fresh = Token.new(user_id: @user.id)
+ fresh.save
+ with_config auth: {token_expires_after: 60} do
+ Token.destroy_all_expired
+ end
+ assert_nil Token.find(expired.id)
+ assert_equal fresh, Token.find(fresh.id)
+ fresh.destroy
+ end
+
+
end