aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/finder_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-11-05 21:27:51 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-11-05 21:27:51 +0000
commit2fbe0ae7a2d945dbd9d0e0abad23afde75db67fb (patch)
tree9e1af551f499881c5d3fe6b73730e45cf4ad2660 /activerecord/test/finder_test.rb
parent5b979ed8ffe5f42747141f632656571f0fd194bf (diff)
downloadrails-2fbe0ae7a2d945dbd9d0e0abad23afde75db67fb.tar.gz
rails-2fbe0ae7a2d945dbd9d0e0abad23afde75db67fb.tar.bz2
rails-2fbe0ae7a2d945dbd9d0e0abad23afde75db67fb.zip
Support nil and Array in :conditions => { attr => value } hashes. Closes #6548.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5435 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/finder_test.rb')
-rw-r--r--activerecord/test/finder_test.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb
index ebc21b5e0c..cf2dfcbb24 100644
--- a/activerecord/test/finder_test.rb
+++ b/activerecord/test/finder_test.rb
@@ -161,10 +161,22 @@ class FinderTest < Test::Unit::TestCase
Company.find(:first, :conditions => { :id => 2, :dhh => true })
}
end
-
+
def test_hash_condition_find_with_escaped_characters
Company.create("name" => "Ain't noth'n like' \#stuff")
- assert Company.find(:first, :conditions => { :name => "Ain't noth'n like' \#stuff"})
+ assert Company.find(:first, :conditions => { :name => "Ain't noth'n like' \#stuff" })
+ end
+
+ def test_hash_condition_find_with_array
+ p1, p2 = Post.find(:all, :limit => 2, :order => 'id asc')
+ assert_equal [p1, p2], Post.find(:all, :conditions => { :id => [p1, p2] }, :order => 'id asc')
+ assert_equal [p1, p2], Post.find(:all, :conditions => { :id => [p1, p2.id] }, :order => 'id asc')
+ end
+
+ def test_hash_condition_find_with_nil
+ topic = Topic.find(:first, :conditions => { :last_read => nil } )
+ assert_not_nil topic
+ assert_nil topic.last_read
end
def test_bind_variables