Skip to content
This repository
Browse code

Fix polymorphic_path doesn't modify options hash [#2099 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
commit 21cd4c0e93fc6ac5497ada787d286c07f627e5ba 1 parent 83c1934
Mislav Marohnić authored June 21, 2009 lifo committed June 21, 2009
3  actionpack/lib/action_controller/routing/generation/polymorphic_routes.rb
@@ -112,8 +112,7 @@ def polymorphic_url(record_or_hash_or_array, options = {})
112 112
     # Returns the path component of a URL for the given record. It uses
113 113
     # <tt>polymorphic_url</tt> with <tt>:routing_type => :path</tt>.
114 114
     def polymorphic_path(record_or_hash_or_array, options = {})
115  
-      options[:routing_type] = :path
116  
-      polymorphic_url(record_or_hash_or_array, options)
  115
+      polymorphic_url(record_or_hash_or_array, options.merge(:routing_type => :path))
117 116
     end
118 117
 
119 118
     %w(edit new).each do |action|
9  actionpack/test/activerecord/polymorphic_routes_test.rb
@@ -234,10 +234,13 @@ def test_polymorphic_path_does_not_modify_arguments
234 234
     with_admin_test_routes do
235 235
       @project.save
236 236
       @task.save
  237
+
  238
+      options = {}
237 239
       object_array = [:admin, @project, @task]
238  
-      assert_no_difference 'object_array.size' do
239  
-        polymorphic_url(object_array)
240  
-      end
  240
+      original_args = [object_array.dup, options.dup]
  241
+
  242
+      assert_no_difference('object_array.size') { polymorphic_path(object_array, options) }
  243
+      assert_equal original_args, [object_array, options]
241 244
     end
242 245
   end
243 246
   

0 notes on commit 21cd4c0

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