diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-08-07 18:32:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-07 18:32:06 +0200 |
commit | 15a600f9fe815ad6423875b69cd439a41e9636eb (patch) | |
tree | 3b85ba0b86d6fc83c0c3022bf5922662272f34a5 /actionpack/test/controller | |
parent | c4f8c45ba57e97e8dfc99f8bf6c2fbfd39abd58b (diff) | |
parent | 23ce9e9b99771080355dccfee6a8453e103682e4 (diff) | |
download | rails-15a600f9fe815ad6423875b69cd439a41e9636eb.tar.gz rails-15a600f9fe815ad6423875b69cd439a41e9636eb.tar.bz2 rails-15a600f9fe815ad6423875b69cd439a41e9636eb.zip |
Merge pull request #26003 from darkbaby123/fix_xhr_overwrite_headers_in_test
Fix Accept header overwritten issue when "xhr: true" in integration test
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/integration_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 0d6a441789..210757fb76 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -403,6 +403,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest respond_to do |format| format.html { render plain: "OK", status: 200 } format.js { render plain: "JS OK", status: 200 } + format.json { render json: "JSON OK", status: 200 } format.xml { render xml: "<root></root>", status: 200 } format.rss { render xml: "<root></root>", status: 200 } format.atom { render xml: "<root></root>", status: 200 } @@ -727,6 +728,18 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest assert_includes @response.headers, "c" end + def test_accept_not_overriden_when_xhr_true + with_test_route_set do + get "/get", headers: { "Accept" => "application/json" }, xhr: true + assert_equal "application/json", request.accept + assert_equal "application/json", response.content_type + + get "/get", headers: { "HTTP_ACCEPT" => "application/json" }, xhr: true + assert_equal "application/json", request.accept + assert_equal "application/json", response.content_type + end + end + private def with_default_headers(headers) original = ActionDispatch::Response.default_headers |