Skip to content

Instantly share code, notes, and snippets.

@lewispb
Last active August 10, 2023 17:48
Show Gist options
  • Save lewispb/8e5d1d5a940f914d0fda16f41f2e3154 to your computer and use it in GitHub Desktop.
Save lewispb/8e5d1d5a940f914d0fda16f41f2e3154 to your computer and use it in GitHub Desktop.
module SessionSystemTestHelper
def sign_in_as(user)
visit root_url # any fast-to-load page will do
cookie_jar = ActionDispatch::TestRequest.create.cookie_jar
cookie_jar.signed[:session_token] = user.sessions.create.token
page.driver.browser.manage.add_cookie(name: "session_token", value: cookie_jar[:session_token], sameSite: :Lax, httpOnly: true)
end
end
@lewispb
Copy link
Author

lewispb commented Aug 10, 2023

For the initial page load you can use a blank html page, so it's as fast as possible.

Something like visit root_url + "blank.html" where blank.html is a file served from /public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment