Permalink
Browse files

apply [6648] to 1.2 stable

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@6651 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent cdc26bd commit 0fd9743ae1e20a7c28409ce1cdfa02dc965733e6 @technoweenie technoweenie committed May 2, 2007
@@ -1,5 +1,7 @@
*SVN*
+* Update UrlWriter to accept :anchor parameter. Closes #6771. [octopod]
+
* Replace the current block/continuation filter chain handling by an implementation based on a simple loop. Closes #8226 [Stefan Kaes]
* Return the string representation from an Xml Builder when rendering a partial. #5044 [tpope]
@@ -52,8 +52,9 @@ def url_for(options)
# Delete the unused options to prevent their appearance in the query string
[:protocol, :host, :port].each { |k| options.delete k }
end
+ anchor = "##{options.delete(:anchor)}" if options.key?(:anchor)
url << Routing::Routes.generate(options, {})
- return url
+ return "#{url}#{anchor}"
end
end
@@ -17,7 +17,13 @@ def test_overwrite_params
assert_match %r(/hi/hi/2$), u
end
-
+ def test_anchor
+ assert_equal(
+ 'http://test.host/c/a/i#anchor',
+ @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :anchor => 'anchor')
+ )
+ end
+
private
def split_query_string(str)
[str[0].chr] + str[1..-1].split(/&/).sort
@@ -75,6 +81,12 @@ def test_protocol
W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https')
)
end
+
+ def test_anchor
+ assert_equal('/c/a#anchor',
+ W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :anchor => 'anchor')
+ )
+ end
def test_named_route
ActionController::Routing::Routes.draw do |map|

0 comments on commit 0fd9743

Please sign in to comment.