diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-07-08 00:38:06 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-07-08 00:38:06 +0000 |
commit | 7767e33b4320231b8cdff48c36f180381370e585 (patch) | |
tree | 052a8349dd9f64f9f21fbaf42e64211372cc530f | |
parent | 91317ad61febda0476aa72c3fb1e4763c777227b (diff) | |
download | rails-7767e33b4320231b8cdff48c36f180381370e585.tar.gz rails-7767e33b4320231b8cdff48c36f180381370e585.tar.bz2 rails-7767e33b4320231b8cdff48c36f180381370e585.zip |
Don't modify options parameters in-place. Closes #3819.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4584 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 2 | ||||
-rw-r--r-- | activerecord/test/finder_test.rb | 15 |
3 files changed, 17 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 124546d579..1884c47d8e 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Don't modify options parameters in-place. #3819 [mpalmer@hezmatt.org] + * PostgreSQL: correctly quote the ' in pk_and_sequence_for. #5462 [tietew@tietew.net] * PostgreSQL: correctly quote microseconds in timestamps. #5641 [rick@rickbradley.com] diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 1c8c819efa..94b6645a17 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1390,7 +1390,7 @@ module ActiveRecord #:nodoc: end def extract_options_from_args!(args) #:nodoc: - args.last.is_a?(Hash) ? args.pop : {} + args.last.is_a?(Hash) ? args.pop.dup : {} end VALID_FIND_OPTIONS = [ :conditions, :include, :joins, :limit, :offset, diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb index 23b6508f99..229de2aa18 100644 --- a/activerecord/test/finder_test.rb +++ b/activerecord/test/finder_test.rb @@ -5,9 +5,10 @@ require 'fixtures/reply' require 'fixtures/entrant' require 'fixtures/developer' require 'fixtures/post' +require 'fixtures/author' class FinderTest < Test::Unit::TestCase - fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts, :accounts + fixtures :authors, :companies, :topics, :entrants, :developers, :developers_projects, :posts, :accounts def test_find assert_equal(topics(:first).title, Topic.find(1).title) @@ -449,6 +450,18 @@ class FinderTest < Test::Unit::TestCase assert_equal ["37signals","Summit","Microsoft", "Flamboyant Software", "Ex Nihilo", "RailsCore", "Leetsoft", "Jadedpixel"], Company.connection.select_values("SELECT name FROM companies ORDER BY id") end + def test_find_doesnt_mangle_parameters + author = Author.find(1) + + args = [:all, {:conditions => "body like '%t%'"}] + + author.posts.each do |p| + assert_equal Post.find(p.id).comments.length, + p.comments.find(*args).length, + "Post ##{p.id} doesn't find correct number of comments" + end + end + protected def bind(statement, *vars) if vars.first.is_a?(Hash) |