summaryrefslogtreecommitdiff
path: root/test/unit/token_test.rb
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2017-12-09 05:45:47 -0800
committerazul <azul@riseup.net>2017-12-09 05:45:47 -0800
commit89b879a3e5ee27bfc90751dcd02aa2213262cc5f (patch)
treede610d5ef7146c073b7129a20762838d78aeca03 /test/unit/token_test.rb
parent90c3fc431133cf18d83afd8e394e45c0bd5f63ac (diff)
parent7120117687e2e6078d7e94ddb9e8b93e8ad5f2e3 (diff)
Merge branch 'upgrade/gemfile' into 'master'
Upgrade/gemfile See merge request leap/webapp!55
Diffstat (limited to 'test/unit/token_test.rb')
-rw-r--r--test/unit/token_test.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/test/unit/token_test.rb b/test/unit/token_test.rb
index ce7edaa..3015c9a 100644
--- a/test/unit/token_test.rb
+++ b/test/unit/token_test.rb
@@ -64,7 +64,7 @@ class TokenTest < ActiveSupport::TestCase
end
test "Token.destroy_all_expired is noop if no expiry is set" do
- expired = FactoryGirl.create :token, last_seen_at: 2.hours.ago
+ expired = create_token last_seen_at: 2.hours.ago
with_config auth: {} do
Token.destroy_all_expired
end
@@ -72,8 +72,8 @@ class TokenTest < ActiveSupport::TestCase
end
test "Token.destroy_all_expired cleans up expired tokens only" do
- expired = FactoryGirl.create :token, last_seen_at: 2.hours.ago
- fresh = FactoryGirl.create :token
+ expired = create_token last_seen_at: 2.hours.ago
+ fresh = create_token
with_config auth: {token_expires_after: 60} do
Token.destroy_all_expired
end
@@ -83,7 +83,7 @@ class TokenTest < ActiveSupport::TestCase
end
test "Token.destroy_all_expired does not interfere with expired.authenticate" do
- expired = FactoryGirl.create :token, last_seen_at: 2.hours.ago
+ expired = create_token last_seen_at: 2.hours.ago
with_config auth: {token_expires_after: 60} do
Token.destroy_all_expired
end
@@ -91,7 +91,7 @@ class TokenTest < ActiveSupport::TestCase
end
test "active logout (destroy) prevents reuse" do
- token = FactoryGirl.create :token
+ token = create_token
same = Token.find(token.id)
token.destroy
assert_raises CouchRest::NotFound do
@@ -100,7 +100,7 @@ class TokenTest < ActiveSupport::TestCase
end
test "logout works on prolonged token" do
- token = FactoryGirl.create :token
+ token = create_token
same = Token.find(token.id)
token.touch
same.destroy
@@ -108,11 +108,14 @@ class TokenTest < ActiveSupport::TestCase
end
test 'second destroy carries on' do
- token = FactoryGirl.create :token
+ token = create_token
same = Token.find(token.id)
token.destroy
same.destroy
assert_nil Token.find(same.id)
end
+ def create_token(attrs = {})
+ FactoryBot.create :token, attrs
+ end
end