I have been at this for a few hours, still can't figure it out. I have 2 tests on 2 actions on a nested resources controller. requests
is the parent resources route, and response
is the nested resources route.
These 2 tests give me a no route matches
error. Does not make sense. In the first test, it tries to run the update
action instead of the edit
. Here are my tests:
test "should get edit" do
assert_routing edit_request_response_path(@myresponse.request_id, @myresponse), { :controller => "responses", :action => "edit", :request_id => @myresponse.request_id.to_s, :id => @myresponse.id.to_s }
get :edit, params: { id: @myresponse, request_id: @myresponse.request_id }
assert_response :success
end
test "should update response" do
post :update, :request_id => @myresponse.request_id, response: { body: @myresponse.body, request_id: @myresponse.request_id, status: @myresponse.status, subject: @myresponse.subject, user_id: @myresponse.user_id }
assert_redirected_to response_path(assigns(:response))
end
Here are the errors:
3) Error:
ResponsesControllerTest#test_should_get_edit:
ActionController::UrlGenerationError: No route matches {:action=>"edit", :controller=>"responses", :params=>{:id=>"980190962", :request_id=>"999788447"}}
test/controllers/responses_controller_test.rb:43:in `block in <class:ResponsesControllerTest>'
4) Error:
ResponsesControllerTest#test_should_update_response:
ActionController::UrlGenerationError: No route matches {:action=>"update", :controller=>"responses", :request_id=>"999788447", :response=>{:body=>"This is the body", :request_id=>"999788447", :status=>"draft", :subject=>"This is the subject", :user_id=>"175178709"}}
test/controllers/responses_controller_test.rb:48:in `block in <class:ResponsesControllerTest>'
Aucun commentaire:
Enregistrer un commentaire