mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04:00
Fix overwrite params. Closes #1909
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2144 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Fixed overwrite_params
|
||||
|
||||
* Added ActionController::Base.benchmark and ActionController::Base.silence to allow for easy benchmarking and turning off the log
|
||||
|
||||
* Updated vendor copy of html-scanner to support better xml parsing
|
||||
|
||||
@@ -36,6 +36,10 @@ module ActionController
|
||||
def rewrite_path(options)
|
||||
options = options.symbolize_keys
|
||||
options.update(options[:params].symbolize_keys) if options[:params]
|
||||
if (overwrite = options.delete(:overwrite_params))
|
||||
options.update(@parameters)
|
||||
options.update(overwrite)
|
||||
end
|
||||
RESERVED_OPTIONS.each {|k| options.delete k}
|
||||
path, extra_keys = Routing::Routes.generate(options.dup, @request) # Warning: Routes will mutate and violate the options hash
|
||||
|
||||
|
||||
@@ -23,5 +23,15 @@ class UrlRewriterTests < Test::Unit::TestCase
|
||||
def test_escape_spaces_build_query_string_selected_keys
|
||||
assert_equal '?x=hello+world', @rewriter.send(:build_query_string, {:x => 'hello world', :y => 'goodbye world'}, [:x])
|
||||
end
|
||||
|
||||
def test_overwrite_params
|
||||
@params[:controller] = 'hi'
|
||||
@params[:action] = 'bye'
|
||||
@params[:id] = '2'
|
||||
|
||||
assert_equal '/hi/hi/2', @rewriter.rewrite(:only_path => true, :overwrite_params => {:action => 'hi'})
|
||||
u = @rewriter.rewrite(:only_path => false, :overwrite_params => {:action => 'hi'})
|
||||
assert_match %r(/hi/hi/2$), u
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user