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)