With actions such as :show and :edit, I can just http GET them. But since the :update action has no template, I can’t issue a GET without it complaining about the missing template. That makes sense, so I tried to directly call @controller.update in my test, but I get an error on the respond_to block:
NoMethodError: undefined method `parameters' for nil:NilClass
How do I specify the requested format to be :html? I am passing in a parameter hash for the model’s attributes, FWIW. Thanks for any advice.
Edit:
I since tried invoking @controller.update (after setting params[]) in the console and that error quoted above bubbled up from here: /actionpack-2.3.8/lib/action_controller/mime_responds.rb
I also tried PUT instead of GET, but still got “Missing Template update.erb”.
Also, I managed to find out that this error of missing template is caused by having anything other than a redirect or render in the code block marked HERE:
respond_to do |format|
if @model.update_attributes(params[:model])
flash[:notice] = 'note!'
format.html { **HERE** }
...
I have a method call there that is just a conditional to redirect to the proper place. I can, in principle, understand why it might look for a template to render since it may not be aware that there is a redirect further downstream, but what I don’t understand is how come my web application doesn’t run into the same error as my functional test.
put :updatein your test. If you have code like@my_model.update_attributes(params[:my_model])in the controller then you would callput :update, :id => <whatever>, :my_model => {:foo => 'bar'}in your test.:htmlis the default format, so you don’t need to specify it. If you really wanted to, you could doput :update, :format => :html. But again, not necessary.params, notparameters, so you might be accessing the wrong hashOverall this question could use some more detail about what you’re trying to do and what your current code looks like.