diff options
author | Josh Kalderimis <josh.kalderimis@gmail.com> | 2011-03-31 18:18:11 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-03-31 18:53:27 +0200 |
commit | 48404a751d7cab1556c390a5915c90947d56b46e (patch) | |
tree | 0c28195bb20eb05c8cb745a7218570d4d292fc71 /actionpack/test/controller | |
parent | 9766997f4ce26fe0d97d7b9eebf885ddb517c80c (diff) | |
download | rails-48404a751d7cab1556c390a5915c90947d56b46e.tar.gz rails-48404a751d7cab1556c390a5915c90947d56b46e.tar.bz2 rails-48404a751d7cab1556c390a5915c90947d56b46e.zip |
only try to display an api template in responders if the request is a get or there are no errors
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/mime_responds_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index eead857927..4fde08b3f5 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -558,6 +558,10 @@ class RespondWithController < ActionController::Base respond_with(resource, :location => "http://test.host/", :status => :created) end + def using_invalid_resource_with_template + respond_with(resource) + end + def using_resource_with_responder responder = proc { |c, r, o| c.render :text => "Resource name is #{r.first.name}" } respond_with(resource, :responder => responder) @@ -970,6 +974,23 @@ class RespondWithControllerTest < ActionController::TestCase assert_equal nil, @response.location end + def test_using_invalid_resource_with_template + errors = { :name => :invalid } + Customer.any_instance.stubs(:errors).returns(errors) + + @request.accept = "text/xml" + + post :using_invalid_resource_with_template + assert_equal errors.to_xml, @response.body + assert_equal 422, @response.status + assert_equal nil, @response.location + + put :using_invalid_resource_with_template + assert_equal errors.to_xml, @response.body + assert_equal 422, @response.status + assert_equal nil, @response.location + end + def test_using_resource_with_responder get :using_resource_with_responder assert_equal "Resource name is david", @response.body |