From 2fbe0ae7a2d945dbd9d0e0abad23afde75db67fb Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 5 Nov 2006 21:27:51 +0000 Subject: 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 --- activerecord/test/finder_test.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'activerecord/test') 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 -- cgit v1.2.3