require "test_helper"
class UserFlowsTest < ActionDispatch::IntegrationTest
setup do
@user = users(:one)
end
test "some test"
sign_in @user
post post_path, params: {
post: {
title: "A Sample Post"
# This is better than calling @user.id because it ensures the user_id is actually being set through the current_user.
# and more closely matches what happens in a browser.
user_id: @controller.send(:current_user).id
}
}
end
end
Last active
June 9, 2021 19:09
-
-
Save stevepolitodesign/3f621e487596a260b8a569de368b3479 to your computer and use it in GitHub Desktop.
Call current_user in a Integration Test
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment