aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJeffrey Hardy <packagethief@gmail.com>2009-06-02 13:28:44 -0400
committerJeremy Kemper <jeremy@bitsweat.net>2009-08-26 14:11:26 -0700
commit05b529ca57f75ce64540b9d34597e0c3bfe1fca7 (patch)
treed1f751066283ba20581ab73c4f006872fcbcc393 /actionpack/test
parentcc9af20da7af98464ece18d4abc6a22ef3f00b5d (diff)
downloadrails-05b529ca57f75ce64540b9d34597e0c3bfe1fca7.tar.gz
rails-05b529ca57f75ce64540b9d34597e0c3bfe1fca7.tar.bz2
rails-05b529ca57f75ce64540b9d34597e0c3bfe1fca7.zip
UrlRewriter#rewrite_url should call #to_param on the value given in :anchor option, just as #url_for does
[#2746 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/url_rewriter_test.rb26
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 ad915e7a57..9b8d07222b 100644
--- a/actionpack/test/controller/url_rewriter_test.rb
+++ b/actionpack/test/controller/url_rewriter_test.rb
@@ -46,6 +46,20 @@ class UrlRewriterTests < ActionController::TestCase
)
end
+ def test_anchor_should_call_to_param
+ assert_equal(
+ 'http://test.host/c/a/i#anchor',
+ @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :anchor => Struct.new(:to_param).new('anchor'))
+ )
+ end
+
+ def test_anchor_should_be_cgi_escaped
+ assert_equal(
+ 'http://test.host/c/a/i#anc%2Fhor',
+ @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :anchor => Struct.new(:to_param).new('anc/hor'))
+ )
+ end
+
def test_overwrite_params
@params[:controller] = 'hi'
@params[:action] = 'bye'
@@ -110,6 +124,18 @@ class UrlWriterTests < ActionController::TestCase
)
end
+ def test_anchor_should_call_to_param
+ assert_equal('/c/a#anchor',
+ W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :anchor => Struct.new(:to_param).new('anchor'))
+ )
+ end
+
+ def test_anchor_should_be_cgi_escaped
+ assert_equal('/c/a#anc%2Fhor',
+ W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :anchor => Struct.new(:to_param).new('anc/hor'))
+ )
+ end
+
def test_default_host
add_host!
assert_equal('http://www.basecamphq.com/c/a/i',