From 28767075f4b0a8d610e14a095da1babc363af05a Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 10 Jan 2007 10:13:18 +0000 Subject: 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 --- activerecord/test/finder_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activerecord/test') 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 }) } -- cgit v1.2.3