Routing Error when testing and using restful routes

When testing I get this code I get the following error:

test “should update proveedor” do
put :update, :id => proveedores(:iberdrola).to_param, :proveedor =>
{:fax => ‘943456578’}
assert_redirected_to proveedor_path(assigns(:proveedor))
end

  1. Error:
    test_should_update_proveedor(ProveedoresControllerTest):
    ActionController::RoutingError: proveedor_url failed to generate from
    {:action=>“show”, :id=>nil, :controller=>“proveedo
    res”}, expected: {:action=>“show”, :controller=>“proveedores”}, diff:
    {:id=>nil}
    (eval):16:in proveedor_path' /test/functional/proveedores_controller_test.rb:37:intest_should_update_proveedor’

I have searched the web and I know that the problem is that
assigns(:proveedor) are not putting the param id that is necessary to
generate the correct URL, but why? Any idea?

Hi Juan K.

 What is in your update action? Can you paste it? I think the id for 

proveedor is not setting in update…So the value of id is getting as
nil. Check assert assigns(:proveedor) also

Sijo

Yes. I found the problem. The problem was that the controller didn’t
create the proveedor properly and the id were not create properly then.

Thanks!

Sijo k g wrote:

Hi Juan K.

 What is in your update action? Can you paste it? I think the id for 

proveedor is not setting in update…So the value of id is getting as
nil. Check assert assigns(:proveedor) also