Permalink
Browse files

fixing bug with rails use of rack-test

  • Loading branch information...
1 parent b0f0591 commit 1a61a797aa5ed4c3956a62f3352f1a674b288d54 @tenderlove tenderlove committed with josevalim Sep 23, 2010
Showing with 5 additions and 3 deletions.
  1. +1 −1 actionpack/actionpack.gemspec
  2. +4 −2 actionpack/lib/action_dispatch/testing/integration.rb
View
2 actionpack/actionpack.gemspec
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.add_dependency('builder', '~> 2.1.2')
s.add_dependency('i18n', '~> 0.4.1')
s.add_dependency('rack', '~> 1.2.1')
- s.add_dependency('rack-test', '~> 0.5.4')
+ s.add_dependency('rack-test', '~> 0.5.5')
s.add_dependency('rack-mount', '~> 0.6.13')
s.add_dependency('tzinfo', '~> 0.3.23')
s.add_dependency('erubis', '~> 2.6.6')
View
6 actionpack/lib/action_dispatch/testing/integration.rb
@@ -257,17 +257,19 @@ def process(method, path, parameters = nil, rack_environment = nil)
end
end
+ port = host.split(':')[1]
+
env = {
:method => method,
:params => parameters,
"SERVER_NAME" => host.split(':')[0],
- "SERVER_PORT" => (https? ? "443" : "80"),
+ "SERVER_PORT" => (port ? port : (https? ? "443" : "80")),
@Empact
Empact added a line comment Sep 24, 2010

Niggle: double ternary. Could be

port || (https? ? '443' : '80')
@spastorino
Ruby on Rails member
spastorino added a line comment Sep 25, 2010

Yeah it's better that way, can you provide a patch? so we can assign you as the committer, thanks.

@spastorino
Ruby on Rails member
spastorino added a line comment Sep 26, 2010

I was waiting your patch finally i did it. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
"HTTPS" => https? ? "on" : "off",
"rack.url_scheme" => https? ? "https" : "http",
"REQUEST_URI" => path,
- "HTTP_HOST" => host,
+ "HTTP_HOST" => [host, port].compact.join(':'),
@Empact
Empact added a line comment Sep 24, 2010

Won't this double up the port? After all the host.split above is non-modifying, so if the port was present in host, it still is.

@josevalim
Ruby on Rails member
josevalim added a line comment Sep 24, 2010

Could you please try to come up with a test case?

@spastorino
Ruby on Rails member
spastorino added a line comment Sep 26, 2010

Empact you're right i fixed it because it was making a test fail since rack-test 0.5.6 was released. Thanks again ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
"REMOTE_ADDR" => remote_addr,
"CONTENT_TYPE" => "application/x-www-form-urlencoded",
"HTTP_ACCEPT" => accept

0 comments on commit 1a61a79

Please sign in to comment.