dimanche 31 janvier 2021

rails testing with devise-defined current_user

A rails controller test is invoking an action where its form calls

  f.hidden_field :user_id, value: current_user.id

the controllerTest attempts to define the current_user in the action call

test "should get edit" do
  @shopusers.each do |user|
    current_user = user
    sign_in user

but fails specifically on that line:

ActionView::Template::Error: undefined method `user_id' for nil:NilClass
    app/views/transactions/_form.html.erb:14

How should one go about defining the current_user for the purposes of a test

Aucun commentaire:

Enregistrer un commentaire