1
0
Fork 0
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:
Joshua Peek 2009-04-28 16:25:04 -05:00
parent afa7d7ff05
commit d63b42da36
2 changed files with 7 additions and 12 deletions

View file

@ -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)

View file

@ -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