mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Move header injection back into integration tests
This commit is contained in:
parent
afa7d7ff05
commit
d63b42da36
2 changed files with 7 additions and 12 deletions
|
@ -263,7 +263,6 @@ module ActionController
|
||||||
opts = {
|
opts = {
|
||||||
:method => method.to_s.upcase,
|
:method => method.to_s.upcase,
|
||||||
:params => parameters,
|
:params => parameters,
|
||||||
:headers => headers,
|
|
||||||
|
|
||||||
"SERVER_NAME" => host,
|
"SERVER_NAME" => host,
|
||||||
"SERVER_PORT" => (https? ? "443" : "80"),
|
"SERVER_PORT" => (https? ? "443" : "80"),
|
||||||
|
@ -282,6 +281,12 @@ module ActionController
|
||||||
}
|
}
|
||||||
env = ActionDispatch::Test::MockRequest.env_for(@path, opts)
|
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)
|
app = Rack::Lint.new(@app)
|
||||||
status, headers, body = app.call(env)
|
status, headers, body = app.call(env)
|
||||||
response = ::Rack::MockResponse.new(status, headers, body)
|
response = ::Rack::MockResponse.new(status, headers, body)
|
||||||
|
|
|
@ -5,8 +5,6 @@ module ActionDispatch
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def env_for(path, opts)
|
def env_for(path, opts)
|
||||||
headers = opts.delete(:headers)
|
|
||||||
|
|
||||||
method = (opts[:method] || opts["REQUEST_METHOD"]).to_s.upcase
|
method = (opts[:method] || opts["REQUEST_METHOD"]).to_s.upcase
|
||||||
opts[:method] = opts["REQUEST_METHOD"] = method
|
opts[:method] = opts["REQUEST_METHOD"] = method
|
||||||
|
|
||||||
|
@ -48,15 +46,7 @@ module ActionDispatch
|
||||||
uri.query = requestify(params)
|
uri.query = requestify(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
env = ::Rack::MockRequest.env_for(uri.to_s, opts)
|
::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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in a new issue