Skip to content
Browse files

Add deprecation warning for overwrite_params and remove rdoc

[#4073 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent abb8fbd commit cbc0201a3e0145da51baa9d228d88633033521ce @rubys rubys committed with jeremy
View
9 actionpack/lib/action_controller/base.rb
@@ -616,15 +616,6 @@ def send_response
# displayed on:
#
# url_for :controller => 'posts', :action => nil
- #
- # If you explicitly want to create a URL that's almost the same as the current URL, you can do so using the
- # <tt>:overwrite_params</tt> options. Say for your posts you have different views for showing and printing them.
- # Then, in the show view, you get the URL for the print view like this
- #
- # url_for :overwrite_params => { :action => 'print' }
- #
- # This takes the current URL as is and only exchanges the action. In contrast, <tt>url_for :action => 'print'</tt>
- # would have slashed-off the path components after the changed action.
def url_for(options = {})
options ||= {}
case options
View
5 actionpack/lib/action_controller/url_rewriter.rb
@@ -159,6 +159,9 @@ def initialize(request, parameters)
end
def rewrite(options = {})
+ if options.include?(:overwrite_params)
+ ActiveSupport::Deprecation.warn 'The :overwrite_params option is deprecated. Specify all the necessary parameters instead', caller
+ end
rewrite_url(options)
end
@@ -194,7 +197,7 @@ def rewrite_path(options)
options = options.symbolize_keys
options.update(options[:params].symbolize_keys) if options[:params]
- if (overwrite = options.delete(:overwrite_params))
+ if overwrite = options.delete(:overwrite_params)
options.update(@parameters.symbolize_keys)
options.update(overwrite.symbolize_keys)
end
View
16 actionpack/test/controller/url_rewriter_test.rb
@@ -65,9 +65,11 @@ def test_overwrite_params
@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
+ assert_deprecated /overwrite_params/ do
+ 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
def test_overwrite_removes_original
@@ -75,9 +77,11 @@ def test_overwrite_removes_original
@params[:action] = 'list'
@params[:list_page] = 1
- assert_equal '/search/list?list_page=2', @rewriter.rewrite(:only_path => true, :overwrite_params => {"list_page" => 2})
- u = @rewriter.rewrite(:only_path => false, :overwrite_params => {:list_page => 2})
- assert_equal 'http://test.host/search/list?list_page=2', u
+ assert_deprecated /overwrite_params/ do
+ assert_equal '/search/list?list_page=2', @rewriter.rewrite(:only_path => true, :overwrite_params => {"list_page" => 2})
+ u = @rewriter.rewrite(:only_path => false, :overwrite_params => {:list_page => 2})
+ assert_equal 'http://test.host/search/list?list_page=2', u
+ end
end
def test_to_str

0 comments on commit cbc0201

Please sign in to comment.
Something went wrong with that request. Please try again.