From 09df1275691ac44a0b5c05ae13c24b11ed5ef9b5 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Mislav=20Marohni=C4=87?= Date: Sat, 28 Feb 2009 16:05:32 +0100 Subject: [PATCH] fix polymorphic_path doesn't modify options hash --- .../lib/action_controller/polymorphic_routes.rb | 3 +-- .../test/controller/polymorphic_routes_test.rb | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/actionpack/lib/action_controller/polymorphic_routes.rb b/actionpack/lib/action_controller/polymorphic_routes.rb index 924d1aa..aa59998 100644 --- a/actionpack/lib/action_controller/polymorphic_routes.rb +++ b/actionpack/lib/action_controller/polymorphic_routes.rb @@ -112,8 +112,7 @@ module ActionController # Returns the path component of a URL for the given record. It uses # polymorphic_url with :routing_type => :path. 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| diff --git a/actionpack/test/controller/polymorphic_routes_test.rb b/actionpack/test/controller/polymorphic_routes_test.rb index 5329552..eb96064 100644 --- a/actionpack/test/controller/polymorphic_routes_test.rb +++ b/actionpack/test/controller/polymorphic_routes_test.rb @@ -199,10 +199,12 @@ class PolymorphicRoutesTest < ActiveSupport::TestCase end def test_polymorphic_path_does_not_modify_arguments - expects(:admin_article_responses_url).with(@article) - path = [:admin, @article, @response] - assert_no_difference 'path.size' do - polymorphic_url(path) - end + expects(:admin_article_responses_path).with(@article) + route = [:admin, @article, @response] + options = {} + original_args = [route.dup, options.dup] + + polymorphic_path(route, options) + assert_equal original_args, [route, options] end end -- 1.6.1