Merge pull request #17058 from eval/issue-17057

Remove internal options from query string of paths
This commit is contained in:
Rafael Mendonça França 2014-09-25 17:15:00 -03:00
commit f82ecef9ae
3 changed files with 19 additions and 18 deletions

@ -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:

@ -116,27 +116,13 @@ def polymorphic_url(record_or_hash_or_array, options = {})
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 @@ def polymorphic_url_for_action(action, record_or_hash, options)
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:

@ -282,6 +282,15 @@ def test_url_helper_prefixed_with_new
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