aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorSzymon Nowak <szimek@gmail.com>2010-10-11 19:37:03 +0200
committerJosé Valim <jose.valim@gmail.com>2010-10-12 00:56:07 +0200
commit0d3333257156544feba729ba28f6874d5a30d561 (patch)
tree2c2fa4a38b6825c53a72d4c8d3832efdd2f9eed7 /actionpack/test
parent582a088ba7f3e720a259f6e01b3fabcda87484b7 (diff)
downloadrails-0d3333257156544feba729ba28f6874d5a30d561.tar.gz
rails-0d3333257156544feba729ba28f6874d5a30d561.tar.bz2
rails-0d3333257156544feba729ba28f6874d5a30d561.zip
Return a valid empty JSON on successful PUT and DELETE requests. [#5199 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/mime_responds_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index adccfa028f..a898ef76e5 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -709,6 +709,15 @@ class RespondWithControllerTest < ActionController::TestCase
assert_equal " ", @response.body
end
+ def test_using_resource_for_put_with_json_yields_ok_on_success
+ Customer.any_instance.stubs(:to_json).returns('{"name": "David"}')
+ @request.accept = "application/json"
+ put :using_resource
+ assert_equal "application/json", @response.content_type
+ assert_equal 200, @response.status
+ assert_equal "{}", @response.body
+ end
+
def test_using_resource_for_put_with_xml_yields_unprocessable_entity_on_failure
@request.accept = "application/xml"
errors = { :name => :invalid }
@@ -739,6 +748,16 @@ class RespondWithControllerTest < ActionController::TestCase
assert_equal " ", @response.body
end
+ def test_using_resource_for_delete_with_json_yields_ok_on_success
+ Customer.any_instance.stubs(:to_json).returns('{"name": "David"}')
+ Customer.any_instance.stubs(:destroyed?).returns(true)
+ @request.accept = "application/json"
+ delete :using_resource
+ assert_equal "application/json", @response.content_type
+ assert_equal 200, @response.status
+ assert_equal "{}", @response.body
+ end
+
def test_using_resource_for_delete_with_html_redirects_on_failure
with_test_route_set do
errors = { :name => :invalid }