aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/finder_test.rb
diff options
context:
space:
mode:
authormiloops <miloops@gmail.com>2008-11-21 19:20:33 -0300
committerMichael Koziarski <michael@koziarski.com>2008-12-01 20:22:31 +0100
commit97403ad5fdfcdfb2110c6f8fd0ebf43b7afc4859 (patch)
tree77998cf59255d49323d7f7063025ca895e162f62 /activerecord/test/cases/finder_test.rb
parent0c4ba90aa1ea6a8d386c724a55a31e63a13c46ab (diff)
downloadrails-97403ad5fdfcdfb2110c6f8fd0ebf43b7afc4859.tar.gz
rails-97403ad5fdfcdfb2110c6f8fd0ebf43b7afc4859.tar.bz2
rails-97403ad5fdfcdfb2110c6f8fd0ebf43b7afc4859.zip
Add :having option to find, to use in combination with grouped finds. Also added to has_many and has_and_belongs_to_many associations.
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1028 state:committed]
Diffstat (limited to 'activerecord/test/cases/finder_test.rb')
-rw-r--r--activerecord/test/cases/finder_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 153880afbd..d4d770b04e 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -175,6 +175,13 @@ class FinderTest < ActiveRecord::TestCase
assert_equal 4, developers.map(&:salary).uniq.size
end
+ def test_find_with_group_and_having
+ developers = Developer.find(:all, :group => "salary", :having => "sum(salary) > 10000", :select => "salary")
+ assert_equal 3, developers.size
+ assert_equal 3, developers.map(&:salary).uniq.size
+ assert developers.all? { |developer| developer.salary > 10000 }
+ end
+
def test_find_with_entire_select_statement
topics = Topic.find_by_sql "SELECT * FROM topics WHERE author_name = 'Mary'"