diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /spec/support/shared_examples/controllers/known_sign_in_shared_examples.rb | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
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 |