Permalink
Browse files

Fixed that polymorphic routes would modify the input array (closes #1…

…1363) [thomas.lee]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9053 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 3c0fd44 commit db083299465bdb89297e180e9635d4ea102c8e19 @dhh dhh committed Mar 17, 2008
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that polymorphic routes would modify the input array #11363 [thomas.lee]
+
* Added :format option to NumberHelper#number_to_currency to enable better localization support #11149 [lylo]
* Fixed that TextHelper#excerpt would include one character too many #11268 [Irfy]
@@ -68,6 +68,10 @@ module PolymorphicRoutes
# polymorphic_url(record) #-> comments_url()
#
def polymorphic_url(record_or_hash_or_array, options = {})
+ if record_or_hash_or_array.kind_of?(Array)
+ record_or_hash_or_array = record_or_hash_or_array.dup
+ end
+
record = extract_record(record_or_hash_or_array)
format = (options[:action].to_s == "formatted" and record_or_hash_or_array.pop)
namespace = extract_namespace(record_or_hash_or_array)
@@ -125,5 +125,12 @@ def test_polymorphic_path_accepts_options
polymorphic_path(@article, :action => :new)
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
+ end
end
end

0 comments on commit db08329

Please sign in to comment.