mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fix polymorphic_path doesn't modify options hash [#2099 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
committed by
Pratik Naik
parent
83c1934003
commit
21cd4c0e93
@@ -112,8 +112,7 @@ module ActionController
|
||||
# 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 = {})
|
||||
options[:routing_type] = :path
|
||||
polymorphic_url(record_or_hash_or_array, options)
|
||||
polymorphic_url(record_or_hash_or_array, options.merge(:routing_type => :path))
|
||||
end
|
||||
|
||||
%w(edit new).each do |action|
|
||||
|
||||
@@ -234,10 +234,13 @@ class PolymorphicRoutesTest < ActionController::TestCase
|
||||
with_admin_test_routes do
|
||||
@project.save
|
||||
@task.save
|
||||
|
||||
options = {}
|
||||
object_array = [:admin, @project, @task]
|
||||
assert_no_difference 'object_array.size' do
|
||||
polymorphic_url(object_array)
|
||||
end
|
||||
original_args = [object_array.dup, options.dup]
|
||||
|
||||
assert_no_difference('object_array.size') { polymorphic_path(object_array, options) }
|
||||
assert_equal original_args, [object_array, options]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user