diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-10 16:36:01 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-10 16:36:01 +0000 |
commit | 3309268120fade0cd643750a4bedf95097cbced6 (patch) | |
tree | a014ca1505d05d4e5833e396efec357f2b7b0ad6 /activerecord/test/associations_test.rb | |
parent | 3488ff6fc6aa091821088df47ee0ca3ebdd594f0 (diff) | |
download | rails-3309268120fade0cd643750a4bedf95097cbced6.tar.gz rails-3309268120fade0cd643750a4bedf95097cbced6.tar.bz2 rails-3309268120fade0cd643750a4bedf95097cbced6.zip |
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
Diffstat (limited to 'activerecord/test/associations_test.rb')
-rwxr-xr-x | activerecord/test/associations_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
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") |