Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

memoize host with port and refactor the tests which depend on it chan…

…ging

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8164 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 6d0e5eaf06c6f285201bdbb7948c31281f15f8c5 1 parent c07eae4
@NZKoz NZKoz authored
View
2  actionpack/lib/action_controller/request.rb
@@ -166,7 +166,7 @@ def host
# Returns a host:port string for this request, such as example.com or
# example.com:8080.
def host_with_port
- host + port_string
+ @host_with_port ||= host + port_string
end
# Returns the port number of this request as an integer.
View
8 actionpack/test/controller/caching_test.rb
@@ -248,16 +248,22 @@ def test_cache_is_scoped_by_subdomain
@request.host = 'jamis.hostname.com'
get :index
jamis_cache = content_to_cache
-
+
+ reset!
+
@request.host = 'david.hostname.com'
get :index
david_cache = content_to_cache
assert_not_equal jamis_cache, @response.body
+ reset!
+
@request.host = 'jamis.hostname.com'
get :index
assert_equal jamis_cache, @response.body
+ reset!
+
@request.host = 'david.hostname.com'
get :index
assert_equal david_cache, @response.body
View
6 actionpack/test/controller/request_test.rb
@@ -252,11 +252,13 @@ def test_request_uri
end
- def test_host_with_port
+ def test_host_with_default_port
@request.host = "rubyonrails.org"
@request.port = 80
assert_equal "rubyonrails.org", @request.host_with_port
-
+ end
+
+ def test_host_with_non_default_port
@request.host = "rubyonrails.org"
@request.port = 81
assert_equal "rubyonrails.org:81", @request.host_with_port
Please sign in to comment.
Something went wrong with that request. Please try again.