Test auth!
test "requesting current user with token" do
post "/api/graphql", as: :json, params: {
query: <<~QUERY
{
currentUser {
email
}
}
QUERY
}, headers: {
'HTTP_AUTHORIZATION':
ActionController::HttpAuthentication::Token
.encode_credentials(user_tokens(:scott).token)
}
assert_response :success
current_user = JSON.parse(response.body)
.dig(“data", "currentUser")
assert_equal "
[email protected]", current_user["email"]
end