mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Move header injection back into integration tests
This commit is contained in:
@@ -263,7 +263,6 @@ module ActionController
|
||||
opts = {
|
||||
:method => method.to_s.upcase,
|
||||
:params => parameters,
|
||||
:headers => headers,
|
||||
|
||||
"SERVER_NAME" => host,
|
||||
"SERVER_PORT" => (https? ? "443" : "80"),
|
||||
@@ -282,6 +281,12 @@ module ActionController
|
||||
}
|
||||
env = ActionDispatch::Test::MockRequest.env_for(@path, opts)
|
||||
|
||||
(headers || {}).each do |key, value|
|
||||
key = key.to_s.upcase.gsub(/-/, "_")
|
||||
key = "HTTP_#{key}" unless env.has_key?(key) || key =~ /^HTTP_/
|
||||
env[key] = value
|
||||
end
|
||||
|
||||
app = Rack::Lint.new(@app)
|
||||
status, headers, body = app.call(env)
|
||||
response = ::Rack::MockResponse.new(status, headers, body)
|
||||
|
||||
@@ -5,8 +5,6 @@ module ActionDispatch
|
||||
|
||||
class << self
|
||||
def env_for(path, opts)
|
||||
headers = opts.delete(:headers)
|
||||
|
||||
method = (opts[:method] || opts["REQUEST_METHOD"]).to_s.upcase
|
||||
opts[:method] = opts["REQUEST_METHOD"] = method
|
||||
|
||||
@@ -48,15 +46,7 @@ module ActionDispatch
|
||||
uri.query = requestify(params)
|
||||
end
|
||||
|
||||
env = ::Rack::MockRequest.env_for(uri.to_s, opts)
|
||||
|
||||
(headers || {}).each do |key, value|
|
||||
key = key.to_s.upcase.gsub(/-/, "_")
|
||||
key = "HTTP_#{key}" unless env.has_key?(key) || key =~ /^HTTP_/
|
||||
env[key] = value
|
||||
end
|
||||
|
||||
env
|
||||
::Rack::MockRequest.env_for(uri.to_s, opts)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user