diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-10 10:13:18 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-10 10:13:18 +0000 |
commit | 28767075f4b0a8d610e14a095da1babc363af05a (patch) | |
tree | 1ff6ba61f76c9a200870600eb7b8f9b72b2cabb1 /activerecord/test/finder_test.rb | |
parent | d5f642294ccd696c852ba3d538a4f1180c101a4b (diff) | |
download | rails-28767075f4b0a8d610e14a095da1babc363af05a.tar.gz rails-28767075f4b0a8d610e14a095da1babc363af05a.tar.bz2 rails-28767075f4b0a8d610e14a095da1babc363af05a.zip |
Pass a range in :conditions to use the SQL BETWEEN operator. Closes #6974.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5876 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/finder_test.rb')
-rw-r--r-- | activerecord/test/finder_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb index d31d859b44..1e6e4cf6cd 100644 --- a/activerecord/test/finder_test.rb +++ b/activerecord/test/finder_test.rb @@ -136,6 +136,16 @@ class FinderTest < Test::Unit::TestCase assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :approved => true }) } end + def test_find_on_hash_conditions_with_range + assert_equal [1,2], Topic.find(:all, :conditions => { :id => 1..2 }).map(&:id).sort + assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :id => 2..3 }) } + end + + def test_find_on_hash_conditions_with_multiple_ranges + assert_equal [1,2,3], Comment.find(:all, :conditions => { :id => 1..3, :post_id => 1..2 }).map(&:id).sort + assert_equal [1], Comment.find(:all, :conditions => { :id => 1..1, :post_id => 1..10 }).map(&:id).sort + end + def test_find_on_multiple_hash_conditions assert Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => false }) assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) } |