Remove internal options from query string of paths

Fixes #17057
This commit is contained in:
Gert Goet 2014-09-25 17:50:16 +02:00
parent f620299b27
commit 2d08fd2506
3 changed files with 19 additions and 18 deletions

View File

@ -1,3 +1,10 @@
* Fix bug where `routing_type=path` would end up in query string of paths
generated by `edit_` and `new_polymorphic_path`
Fixes #17057.
*Gert Goet*
* Deprecate implicit Array conversion for Response objects. It was added
(using `#to_ary`) so we could conveniently use implicit splatting:

View File

@ -116,27 +116,13 @@ module ActionDispatch
action,
type,
opts
end
# Returns the path component of a URL for the given record. It uses
# <tt>polymorphic_url</tt> with <tt>routing_type: :path</tt>.
def polymorphic_path(record_or_hash_or_array, options = {})
if Hash === record_or_hash_or_array
options = record_or_hash_or_array.merge(options)
record = options.delete :id
return polymorphic_path record, options
end
opts = options.dup
action = opts.delete :action
type = :path
HelperMethodBuilder.polymorphic_method self,
record_or_hash_or_array,
action,
type,
opts
opts = options.reverse_merge(:routing_type => :path)
polymorphic_url(record_or_hash_or_array, opts)
end
@ -159,8 +145,7 @@ module ActionDispatch
end
def polymorphic_path_for_action(action, record_or_hash, options)
options = options.merge(:action => action, :routing_type => :path)
polymorphic_path(record_or_hash, options)
polymorphic_path(record_or_hash, options.merge(:action => action))
end
class HelperMethodBuilder # :nodoc:

View File

@ -282,6 +282,15 @@ class PolymorphicRoutesTest < ActionController::TestCase
end
end
def test_regression_path_helper_prefixed_with_new_and_edit
with_test_routes do
assert_equal "/projects/new", new_polymorphic_path(@project)
@project.save
assert_equal "/projects/#{@project.id}/edit", edit_polymorphic_path(@project)
end
end
def test_url_helper_prefixed_with_edit
with_test_routes do
@project.save