aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2016-08-07 18:32:06 +0200
committerGitHub <noreply@github.com>2016-08-07 18:32:06 +0200
commit15a600f9fe815ad6423875b69cd439a41e9636eb (patch)
tree3b85ba0b86d6fc83c0c3022bf5922662272f34a5 /actionpack/lib
parentc4f8c45ba57e97e8dfc99f8bf6c2fbfd39abd58b (diff)
parent23ce9e9b99771080355dccfee6a8453e103682e4 (diff)
downloadrails-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/lib')
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index 3008d10992..9be3759556 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -366,14 +366,17 @@ module ActionDispatch
"HTTP_ACCEPT" => accept
}
+ wrapped_headers = Http::Headers.from_hash({})
+ wrapped_headers.merge!(headers) if headers
+
if xhr
- headers["HTTP_X_REQUESTED_WITH"] = "XMLHttpRequest"
- headers["HTTP_ACCEPT"] ||= [Mime[:js], Mime[:html], Mime[:xml], "text/xml", "*/*"].join(", ")
+ wrapped_headers["HTTP_X_REQUESTED_WITH"] = "XMLHttpRequest"
+ wrapped_headers["HTTP_ACCEPT"] ||= [Mime[:js], Mime[:html], Mime[:xml], "text/xml", "*/*"].join(", ")
end
# this modifies the passed request_env directly
- if headers.present?
- Http::Headers.from_hash(request_env).merge!(headers)
+ if wrapped_headers.present?
+ Http::Headers.from_hash(request_env).merge!(wrapped_headers)
end
if env.present?
Http::Headers.from_hash(request_env).merge!(env)