I'm writing tests for a Rail 5 app and I'm struggling to test signed-in functionality. I'm using Minitest and Omniauth (specifically Google OAuth).
Most of my methods check for current_user and redirect to root_path if it's not present. I need to write tests that simulate that current_user, preferably specifying the id.
If I do something like this:
test "should load settings for logged in user" do
current_user = {id:1}
get settings_path
assert_response :success
end
The test fails with a redirect to my root_path. I've tried to dig into this and it looks like current_user isn't set when the controller checks.
Apologies if I'm missing something fundamental, but could someone please explain how I can test logged-in functionality?
Aucun commentaire:
Enregistrer un commentaire