From d74da1de8c6ec2a6718823a11bf4f513ddb0c91e Mon Sep 17 00:00:00 2001 From: Dombi Attila <83396+dombesz@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:16:19 +0200 Subject: [PATCH] Mock browser login for integration specs. --- spec/support/authentication_helpers.rb | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/spec/support/authentication_helpers.rb b/spec/support/authentication_helpers.rb index 4921b3498199..efb96c6f279b 100644 --- a/spec/support/authentication_helpers.rb +++ b/spec/support/authentication_helpers.rb @@ -34,20 +34,7 @@ def self.included(base) end def login_as(user) - if is_a?(RSpec::Rails::FeatureExampleGroup) - # If we want to mock having finished the login process - # we must set the user_id in rack.session accordingly - # Otherwise e.g. calls to Warden will behave unexpectantly - # as they will login AnonymousUser - if using_cuprite? && js_enabled? - page.driver.set_cookie( - OpenProject::Configuration["session_cookie_name"], - session_value_for(user).to_s - ) - else - page.set_rack_session(session_value_for(user)) - end - end + allow(User).to receive(:current).and_return user allow(RequestStore).to receive(:[]).and_call_original allow(RequestStore).to receive(:[]).with(:current_user).and_return(user)