diff options
Diffstat (limited to 'spec/support/shared_examples/controllers/known_sign_in_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/controllers/known_sign_in_shared_examples.rb | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/spec/support/shared_examples/controllers/known_sign_in_shared_examples.rb b/spec/support/shared_examples/controllers/known_sign_in_shared_examples.rb index 3f147f942ba..77dd67c77a4 100644 --- a/spec/support/shared_examples/controllers/known_sign_in_shared_examples.rb +++ b/spec/support/shared_examples/controllers/known_sign_in_shared_examples.rb @@ -9,10 +9,8 @@ RSpec.shared_examples 'known sign in' do user.update!(current_sign_in_ip: ip) end - def stub_cookie(value = user.id) - cookies.encrypted[KnownSignIn::KNOWN_SIGN_IN_COOKIE] = { - value: value, expires: KnownSignIn::KNOWN_SIGN_IN_COOKIE_EXPIRY - } + def stub_cookie(value = user.id, expires = KnownSignIn::KNOWN_SIGN_IN_COOKIE_EXPIRY) + cookies.encrypted[KnownSignIn::KNOWN_SIGN_IN_COOKIE] = { value: value, expires: expires } end context 'when the remote IP and the last sign in IP match' do @@ -57,15 +55,13 @@ RSpec.shared_examples 'known sign in' do end it 'notifies the user when the cookie is expired' do - stub_cookie - - travel_to((KnownSignIn::KNOWN_SIGN_IN_COOKIE_EXPIRY + 1.day).from_now) do - expect_next_instance_of(NotificationService) do |instance| - expect(instance).to receive(:unknown_sign_in) - end + stub_cookie(user.id, 1.day.ago) - post_action + expect_next_instance_of(NotificationService) do |instance| + expect(instance).to receive(:unknown_sign_in) end + + post_action end context 'when notify_on_unknown_sign_in global setting is false' do |