diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-18 18:01:28 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-18 18:01:28 +0000 |
commit | 61960e7b37767140e9af68bd5373e06dce08492d (patch) | |
tree | c23a31b689a2470a6185198bd4ac065aefa61456 /actionpack/test | |
parent | a7532f9d5f47cf17c18a17dccff2a6d317d8254e (diff) | |
download | rails-61960e7b37767140e9af68bd5373e06dce08492d.tar.gz rails-61960e7b37767140e9af68bd5373e06dce08492d.tar.bz2 rails-61960e7b37767140e9af68bd5373e06dce08492d.zip |
Added Request#port_string to get something like ":8080" back on 8080 and "" on 80 (or 443 with https).
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@214 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/request_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index 1f38d07a03..ebab660eab 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -23,4 +23,26 @@ class RequestTest < Test::Unit::TestCase @request.host = "dev.www.rubyonrails.co.uk" assert_equal %w( dev www ), @request.subdomains(2) end + + def test_port_string + @request.port = 80 + assert_equal "", @request.port_string + + @request.port = 8080 + assert_equal ":8080", @request.port_string + end + + def test_host_with_port + @request.env['HTTP_HOST'] = "rubyonrails.org:8080" + assert_equal "rubyonrails.org:8080", @request.host_with_port + @request.env['HTTP_HOST'] = nil + + @request.host = "rubyonrails.org" + @request.port = 80 + assert_equal "rubyonrails.org", @request.host_with_port + + @request.host = "rubyonrails.org" + @request.port = 81 + assert_equal "rubyonrails.org:81", @request.host_with_port + end end
\ No newline at end of file |