<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -636,6 +636,18 @@ class HasAndBelongsToManyAssociationsTest &lt; ActiveRecord::TestCase
     assert_equal 3, Developer.find(:all, :include =&gt; {:projects =&gt; :developers}, :conditions =&gt; 'developers_projects_join.joined_on IS NOT NULL', :group =&gt; group.join(&quot;,&quot;)).size
   end
 
+  def test_find_grouped
+    all_posts_from_category1 = Post.find(:all, :conditions =&gt; &quot;category_id = 1&quot;, :joins =&gt; :categories)
+    grouped_posts_of_category1 = Post.find(:all, :conditions =&gt; &quot;category_id = 1&quot;, :group =&gt; &quot;author_id&quot;, :select =&gt; 'count(posts.id) as posts_count', :joins =&gt; :categories)
+    assert_equal 4, all_posts_from_category1.size
+    assert_equal 1, grouped_posts_of_category1.size
+  end
+
+  def test_find_scoped_grouped
+    assert_equal 4, categories(:general).posts_gruoped_by_title.size
+    assert_equal 1, categories(:technology).posts_gruoped_by_title.size
+  end
+
   def test_get_ids
     assert_equal projects(:active_record, :action_controller).map(&amp;:id).sort, developers(:david).project_ids.sort
     assert_equal [projects(:active_record).id], developers(:jamis).project_ids</diff>
      <filename>activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -248,6 +248,11 @@ class HasManyAssociationsTest &lt; ActiveRecord::TestCase
     assert_equal 1, grouped_clients_of_firm1.size
   end
 
+  def test_find_scoped_grouped
+    assert_equal 1, companies(:first_firm).clients_grouped_by_firm_id.length
+    assert_equal 2, companies(:first_firm).clients_grouped_by_name.length
+  end
+
   def test_adding
     force_signal37_to_load_all_clients_of_firm
     natural = Client.new(&quot;name&quot; =&gt; &quot;Natural Company&quot;)</diff>
      <filename>activerecord/test/cases/associations/has_many_associations_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -169,6 +169,12 @@ class FinderTest &lt; ActiveRecord::TestCase
     assert_equal(&quot;fixture_3&quot;, developers.first.name)
   end
 
+  def test_find_with_group
+    developers =  Developer.find(:all, :group =&gt; &quot;salary&quot;)
+    assert_equal 4, developers.size
+    assert_equal 4, developers.uniq(&amp;:salary).size
+  end
+
   def test_find_with_entire_select_statement
     topics = Topic.find_by_sql &quot;SELECT * FROM topics WHERE author_name = 'Mary'&quot;
 </diff>
      <filename>activerecord/test/cases/finder_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -160,8 +160,8 @@ class ReflectionTest &lt; ActiveRecord::TestCase
 
   def test_reflection_of_all_associations
     # FIXME these assertions bust a lot
-    assert_equal 24, Firm.reflect_on_all_associations.size
-    assert_equal 18, Firm.reflect_on_all_associations(:has_many).size
+    assert_equal 26, Firm.reflect_on_all_associations.size
+    assert_equal 20, Firm.reflect_on_all_associations(:has_many).size
     assert_equal 6, Firm.reflect_on_all_associations(:has_one).size
     assert_equal 0, Firm.reflect_on_all_associations(:belongs_to).size
   end</diff>
      <filename>activerecord/test/cases/reflection_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,6 +13,9 @@ class Category &lt; ActiveRecord::Base
   has_and_belongs_to_many :post_with_conditions,
                           :class_name =&gt; 'Post',
                           :conditions =&gt; { :title =&gt; 'Yet Another Testing Title' }
+
+  has_and_belongs_to_many :posts_gruoped_by_title, :class_name =&gt; &quot;Post&quot;, :group =&gt; &quot;title&quot;
+
   def self.what_are_you
     'a category...'
   end</diff>
      <filename>activerecord/test/models/category.rb</filename>
    </modified>
    <modified>
      <diff>@@ -55,6 +55,8 @@ class Firm &lt; Company
   has_many :readonly_clients, :class_name =&gt; 'Client', :readonly =&gt; true
   has_many :clients_using_primary_key, :class_name =&gt; 'Client',
            :primary_key =&gt; 'name', :foreign_key =&gt; 'firm_name'
+  has_many :clients_grouped_by_firm_id, :class_name =&gt; &quot;Client&quot;, :group =&gt; &quot;firm_id&quot;
+  has_many :clients_grouped_by_name, :class_name =&gt; &quot;Client&quot;, :group =&gt; &quot;name&quot;
 
   has_one :account, :foreign_key =&gt; &quot;firm_id&quot;, :dependent =&gt; :destroy, :validate =&gt; true
   has_one :unvalidated_account, :foreign_key =&gt; &quot;firm_id&quot;, :class_name =&gt; 'Account', :validate =&gt; false</diff>
      <filename>activerecord/test/models/company.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>095ad690f3fb6df4e89446dd40e03cf2c204e42a</id>
    </parent>
  </parents>
  <author>
    <name>miloops</name>
    <email>miloops@gmail.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/a37c5ae961366e3d693991b51d0830d40ae37e08</url>
  <id>a37c5ae961366e3d693991b51d0830d40ae37e08</id>
  <committed-date>2008-09-11T13:51:57-07:00</committed-date>
  <authored-date>2008-09-11T13:41:55-07:00</authored-date>
  <message>Improve test coverage when using the group option in find, has_many or has_and_belongs_to_many.

Signed-off-by: Michael Koziarski &lt;michael@koziarski.com&gt;</message>
  <tree>0fa9d5de486f5d2fc317676df182d34040a8da1a</tree>
  <committer>
    <name>Michael Koziarski</name>
    <email>michael@koziarski.com</email>
  </committer>
</commit>
