diff options
author | Zuhao Wan <wanzuhao@gmail.com> | 2014-05-19 19:56:06 +0800 |
---|---|---|
committer | Zuhao Wan <wanzuhao@gmail.com> | 2014-05-20 14:52:06 +0800 |
commit | f0440205f67f9c5acc0b5b8119f1e212035bd57c (patch) | |
tree | 1f934374162b56c63ebb71127e6b170fb1ce1b33 | |
parent | a0eec57ef0fbbbb2910a46ca65bd5b565ca0534c (diff) | |
download | rails-f0440205f67f9c5acc0b5b8119f1e212035bd57c.tar.gz rails-f0440205f67f9c5acc0b5b8119f1e212035bd57c.tar.bz2 rails-f0440205f67f9c5acc0b5b8119f1e212035bd57c.zip |
Add using_resouce_with_json to controller.
-rw-r--r-- | actionpack/test/controller/mime/respond_with_test.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/actionpack/test/controller/mime/respond_with_test.rb b/actionpack/test/controller/mime/respond_with_test.rb index 416b3b81a5..235ff86c24 100644 --- a/actionpack/test/controller/mime/respond_with_test.rb +++ b/actionpack/test/controller/mime/respond_with_test.rb @@ -2,6 +2,10 @@ require 'abstract_unit' require 'controller/fake_models' class RespondWithController < ActionController::Base + class CustomerWithJson < Customer + def to_json; super; end + end + respond_to :html, :json, :touch respond_to :xml, :except => :using_resource_with_block respond_to :js, :only => [ :using_resource_with_block, :using_resource, 'using_hash_resource' ] @@ -38,6 +42,10 @@ class RespondWithController < ActionController::Base respond_with(resource, :location => "http://test.host/", :status => :created) end + def using_resource_with_json + respond_with(CustomerWithJson.new("david", request.delete? ? nil : 13)) + end + def using_invalid_resource_with_template respond_with(resource) end @@ -380,9 +388,8 @@ class RespondWithControllerTest < ActionController::TestCase end def test_using_resource_for_put_with_json_yields_no_content_on_success - Customer.any_instance.stubs(:to_json).returns('{"name": "David"}') @request.accept = "application/json" - put :using_resource + put :using_resource_with_json assert_equal "application/json", @response.content_type assert_equal 204, @response.status assert_equal "", @response.body @@ -431,10 +438,9 @@ class RespondWithControllerTest < ActionController::TestCase end def test_using_resource_for_delete_with_json_yields_no_content_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 + delete :using_resource_with_json assert_equal "application/json", @response.content_type assert_equal 204, @response.status assert_equal "", @response.body |