Skip to content

Instantly share code, notes, and snippets.

@BranLiang
Last active October 19, 2024 01:33
Show Gist options
  • Save BranLiang/370351b3429a262752662e94733c4e5a to your computer and use it in GitHub Desktop.
Save BranLiang/370351b3429a262752662e94733c4e5a to your computer and use it in GitHub Desktop.
Rails 8 authentication setup for controller test
# test/test_helper.rb
def login
post session_url, params: { email_address: users(:one).email_address, password: "password" }
end
# test/controllers/campaigns_controller_test.rb
class CampaignsControllerTest < ActionDispatch::IntegrationTest
setup do
login
@campaign = campaigns(:one)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment