diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-02 20:23:42 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-02 20:23:42 -0300 |
commit | beab403fc31199bbb01f1e6e1ba0f839af047afe (patch) | |
tree | e1bb44ddb80a2a5259f968a1ee3a7b78edbf6ef1 /actionpack/test/controller/mime/respond_to_test.rb | |
parent | f2fc31473f0b0e7c8fe39156413b626358131543 (diff) | |
parent | b00b638b95dc513f4ba854ba3a96b7a8f344e4cc (diff) | |
download | rails-beab403fc31199bbb01f1e6e1ba0f839af047afe.tar.gz rails-beab403fc31199bbb01f1e6e1ba0f839af047afe.tar.bz2 rails-beab403fc31199bbb01f1e6e1ba0f839af047afe.zip |
Merge pull request #16026 from lucasmazza/lm-respond-to-jsonp-fix
Change the JSON renderer to enforce the 'JS' Content Type
Diffstat (limited to 'actionpack/test/controller/mime/respond_to_test.rb')
-rw-r--r-- | actionpack/test/controller/mime/respond_to_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime/respond_to_test.rb b/actionpack/test/controller/mime/respond_to_test.rb index 41503e11a8..c89b95de3b 100644 --- a/actionpack/test/controller/mime/respond_to_test.rb +++ b/actionpack/test/controller/mime/respond_to_test.rb @@ -128,6 +128,12 @@ class RespondToController < ActionController::Base end end + def json_with_callback + respond_to do |type| + type.json { render :json => 'JS', :callback => 'alert' } + end + end + def iphone_with_html_response_type request.format = :iphone if request.env["HTTP_ACCEPT"] == "text/iphone" @@ -511,6 +517,13 @@ class RespondToControllerTest < ActionController::TestCase assert_equal '<html><div id="html">HTML for all_types_with_layout</div></html>', @response.body end + def test_json_with_callback_sets_javascript_content_type + @request.accept = 'application/json' + get :json_with_callback + assert_equal 'alert(JS)', @response.body + assert_equal 'text/javascript', @response.content_type + end + def test_xhr xhr :get, :js_or_html assert_equal 'JS', @response.body |