Make :trailing_slash work with query parameters for url_for. Closes #4004 [nov]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7186 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
f9b7394430
commit
5476a6a6c7
@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Make :trailing_slash work with query parameters for url_for. Closes #4004 [nov]
|
||||
|
||||
* Make sure missing template exceptions actually say which template they were looking for. Closes #8683 [dasil003]
|
||||
|
||||
* Fix errors with around_filters which do not yield, restore 1.1 behaviour with after filters. Closes #8891 [skaes]
|
||||
|
@ -89,9 +89,9 @@ def rewrite_url(options)
|
||||
rewritten_url << ":#{options.delete(:port)}" if options.key?(:port)
|
||||
end
|
||||
|
||||
path = rewrite_path(options)
|
||||
rewritten_url << @request.relative_url_root.to_s unless options[:skip_relative_url_root]
|
||||
rewritten_url << rewrite_path(options)
|
||||
rewritten_url << '/' if options[:trailing_slash]
|
||||
rewritten_url << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path)
|
||||
rewritten_url << "##{options[:anchor]}" if options[:anchor]
|
||||
|
||||
rewritten_url
|
||||
@ -121,4 +121,4 @@ def rewrite_authentication(options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -73,6 +73,16 @@ def test_to_str
|
||||
|
||||
assert_equal 'http://, test.host, /, hi, bye, {"id"=>"2"}', @rewriter.to_str
|
||||
end
|
||||
|
||||
def test_trailing_slash
|
||||
options = {:controller => 'foo', :action => 'bar', :id => '3', :only_path => true}
|
||||
assert_equal '/foo/bar/3', @rewriter.rewrite(options)
|
||||
assert_equal '/foo/bar/3?query=string', @rewriter.rewrite(options.merge({:query => 'string'}))
|
||||
options.update({:trailing_slash => true})
|
||||
assert_equal '/foo/bar/3/', @rewriter.rewrite(options)
|
||||
options.update({:query => 'string'})
|
||||
assert_equal '/foo/bar/3/?query=string', @rewriter.rewrite(options)
|
||||
end
|
||||
end
|
||||
|
||||
class UrlWriterTests < Test::Unit::TestCase
|
||||
|
Loading…
Reference in New Issue
Block a user