Last active
October 19, 2024 01:33
-
-
Save BranLiang/370351b3429a262752662e94733c4e5a to your computer and use it in GitHub Desktop.
Rails 8 authentication setup for controller test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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