From 3309268120fade0cd643750a4bedf95097cbced6 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 10 Nov 2005 16:36:01 +0000 Subject: Add :group option, correspond to GROUP BY, to the find method and to the has_many association. Closes #2818. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2974 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/associations_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index 4ad40f338c..fd15098f36 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -384,6 +384,13 @@ class HasManyAssociationsTest < Test::Unit::TestCase assert_raises(ActiveRecord::RecordNotFound) { companies(:first_firm).clients.find(6) } end + def test_find_grouped + all_clients_of_firm1 = Client.find(:all, :conditions => "firm_id = 1") + grouped_clients_of_firm1 = Client.find(:all, :conditions => "firm_id = 1", :group => "firm_id", :select => 'firm_id, count(id) as clients_count') + assert_equal 2, all_clients_of_firm1.size + assert_equal 1, grouped_clients_of_firm1.size + end + def test_adding force_signal37_to_load_all_clients_of_firm natural = Client.new("name" => "Natural Company") -- cgit v1.2.3