From d839bed40fb7901ea88395d4ba06e58f4b3cc88a Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 8 Dec 2017 18:27:24 +0100 Subject: upgrade: factory_girl -> factory_bot --- test/unit/token_test.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'test/unit/token_test.rb') 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 -- cgit v1.2.3