diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-02-25 20:22:09 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-02-25 20:22:09 +0000 |
commit | b8cd80550f541a2becafa29f926b1c2667b7b650 (patch) | |
tree | 906eaabc3806a62f66d75f237f05713c59f517bf /actionpack/test | |
parent | cd4dbd8cd2fce4c0f0b7ad216003cd8da7732128 (diff) | |
download | rails-b8cd80550f541a2becafa29f926b1c2667b7b650.tar.gz rails-b8cd80550f541a2becafa29f926b1c2667b7b650.tar.bz2 rails-b8cd80550f541a2becafa29f926b1c2667b7b650.zip |
Added :port and :host handling to UrlRewriter (which unified url_for usage, regardless of whether it's called in view or controller) #7616 [alancfrancis]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6235 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/url_rewriter_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb index d3bee976a2..f24e5c9c37 100644 --- a/actionpack/test/controller/url_rewriter_test.rb +++ b/actionpack/test/controller/url_rewriter_test.rb @@ -7,6 +7,22 @@ class UrlRewriterTests < Test::Unit::TestCase @rewriter = ActionController::UrlRewriter.new(@request, @params) end + def test_port + assert_equal('http://test.host:1271/c/a/i', + @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :port => 1271) + ) + end + + def test_protocol_with_and_without_separator + assert_equal('https://test.host/c/a/i', + @rewriter.rewrite(:protocol => 'https', :controller => 'c', :action => 'a', :id => 'i') + ) + + assert_equal('https://test.host/c/a/i', + @rewriter.rewrite(:protocol => 'https://', :controller => 'c', :action => 'a', :id => 'i') + ) + end + def test_overwrite_params @params[:controller] = 'hi' @params[:action] = 'bye' @@ -85,6 +101,16 @@ class UrlWriterTests < Test::Unit::TestCase ) end + def test_protocol_with_and_without_separator + add_host! + assert_equal('https://www.basecamphq.com/c/a/i', + W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https') + ) + assert_equal('https://www.basecamphq.com/c/a/i', + W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https://') + ) + end + def test_named_route ActionController::Routing::Routes.draw do |map| map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index' |