On Apr 22, 2010, at 12:18 PM, Nathan Beyer wrote: > > I have a very simple functional test for a controller, but I need to > set a header field in the request before the invocation of the action, > but the headers seem to be getting reset, even though I'm not doing > multiple requests. Is this not how functional tests are to be used? > > test "test the show requires system header" do > @request.headers["System-Name"] = "Test System" > get :show > assert_response :success > ... > end > > The controller doesn't return a success unless the header is set, so > it fails immediately. > > Is there another idiom that's more appropriate?
I use something along the lines of: request.env['HTTP_ACCEPT'] = 'application/json, text/javascript, */*' request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest' to set up headers for an xhr. You should be able to do something similar for custom headers. Hope this helps. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

