mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
memoize host with port and refactor the tests which depend on it changing
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8164 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
c07eae4d40
commit
6d0e5eaf06
3 changed files with 12 additions and 4 deletions
|
@ -166,7 +166,7 @@ module ActionController
|
|||
# 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.
|
||||
|
|
|
@ -248,16 +248,22 @@ class ActionCacheTest < Test::Unit::TestCase
|
|||
@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
|
||||
|
|
|
@ -252,11 +252,13 @@ class RequestTest < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue