In my user controller I have a before_action for the new page/method. This before_action includes:
@organization = Organization.friendly.find(params[:id])
In my user fixtures I have an organization: one
for user @admin, and in my organizations fixtures I have a record for this organization "one". Still my controller test fails on the above line with the message:
ActiveRecord::RecordNotFound: Couldn't find Organization without an ID
Why is this? Is it not possible to do this in a controller test and should I use an integration test instead? If I can use a controller test (which I here prefer), what is wrong with my code?
The controller test:
test "should get new" do
log_in_as("user", @admin) # Test helper that functions properly
get :new # It fails here on the before_action defined in the users controller.
assert_response :success
end
Aucun commentaire:
Enregistrer un commentaire