Skip to content

Commit

Permalink
Mock browser login for integration specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dombesz committed Dec 18, 2024
1 parent 1d73cab commit d74da1d
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions spec/support/authentication_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d74da1d

Please sign in to comment.