Skip to content

Instantly share code, notes, and snippets.

@lewispb
Last active August 10, 2023 17:48
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