aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJosh Kalderimis <josh.kalderimis@gmail.com>2010-11-23 00:31:03 +0100
committerJosé Valim <jose.valim@gmail.com>2010-11-23 09:54:42 +0100
commit2fe43b694f36ddb2062a91eebe61a035147265b1 (patch)
treeea99e4fc380ce7b836a3a332337fbdaad4e4f84f /actionpack/test
parent9938a3fc78bf8e066d2cdfe17f3710e0e6b85a36 (diff)
downloadrails-2fe43b694f36ddb2062a91eebe61a035147265b1.tar.gz
rails-2fe43b694f36ddb2062a91eebe61a035147265b1.tar.bz2
rails-2fe43b694f36ddb2062a91eebe61a035147265b1.zip
:subdomain, :domain and :tld_length options can now be used in url_for, allowing for easy manipulation of the host during link generation.
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/url_for_test.rb23
-rw-r--r--actionpack/test/dispatch/request_test.rb6
2 files changed, 25 insertions, 4 deletions
diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb
index 4c07ca4cc3..1f62d29e80 100644
--- a/actionpack/test/controller/url_for_test.rb
+++ b/actionpack/test/controller/url_for_test.rb
@@ -17,7 +17,7 @@ module AbstractController
end
def test_exception_is_thrown_without_host
- assert_raise RuntimeError do
+ assert_raise ArgumentError do
W.new.url_for :controller => 'c', :action => 'a', :id => 'i'
end
end
@@ -60,6 +60,27 @@ module AbstractController
)
end
+ def test_subdomain_may_be_changed
+ add_host!
+ assert_equal('http://api.basecamphq.com/c/a/i',
+ W.new.url_for(:subdomain => 'api', :controller => 'c', :action => 'a', :id => 'i')
+ )
+ end
+
+ def test_domain_may_be_changed
+ add_host!
+ assert_equal('http://www.37signals.com/c/a/i',
+ W.new.url_for(:domain => '37signals.com', :controller => 'c', :action => 'a', :id => 'i')
+ )
+ end
+
+ def test_tld_length_may_be_changed
+ add_host!
+ assert_equal('http://mobile.www.basecamphq.com/c/a/i',
+ W.new.url_for(:subdomain => 'mobile', :tld_length => 2, :controller => 'c', :action => 'a', :id => 'i')
+ )
+ end
+
def test_port
add_host!
assert_equal('http://www.basecamphq.com:3000/c/a/i',
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb
index 4764a8c2a8..d140ea8358 100644
--- a/actionpack/test/dispatch/request_test.rb
+++ b/actionpack/test/dispatch/request_test.rb
@@ -164,12 +164,12 @@ class RequestTest < ActiveSupport::TestCase
assert !request.standard_port?
end
- test "port string" do
+ test "optional port" do
request = stub_request 'HTTP_HOST' => 'www.example.org:80'
- assert_equal "", request.port_string
+ assert_equal nil, request.optional_port
request = stub_request 'HTTP_HOST' => 'www.example.org:8080'
- assert_equal ":8080", request.port_string
+ assert_equal 8080, request.optional_port
end
test "full path" do