<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,7 +4,7 @@ class ModerationsController &lt; ApplicationController
   cache_sweeper :post_sweeper, :only =&gt; %w(update destroy)
 
   def index
-    @comments = Comment.find_unmoderated(:all,:include =&gt; :post)
+    @comments = Comment.unmoderated.find(:all, :include =&gt; :post)
   end
 
   def show
@@ -35,6 +35,6 @@ class ModerationsController &lt; ApplicationController
   end
 private
   def find_comment
-    @comment = Comment.find_unmoderated(params[:id])
+    @comment = Comment.unmoderated.find(params[:id])
   end
 end</diff>
      <filename>app/controllers/moderations_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,21 +1,13 @@
 class Comment &lt; ActiveRecord::Base
   belongs_to :post
-  # after_create :increment_moderated_comments_counter
   before_save :convert_body
   before_destroy :decrement_moderated_comments_counter
 
   attr_protected :post_id,:body,:moderated
   validates_presence_of :author
 
-  def Comment.moderated
-    find(:all,:conditions =&gt; {:moderated =&gt; true })
-  end
-
-  def Comment.find_unmoderated(*args)
-    with_scope(:find =&gt; {:conditions =&gt; &quot;moderated = 'f'&quot;}) do
-      find(*args)
-    end
-  end
+  named_scope :moderated, :conditions =&gt; {:moderated =&gt; true}
+  named_scope :unmoderated, :conditions =&gt; {:moderated =&gt; false}
 
   def moderate
     unless moderated?
@@ -34,12 +26,8 @@ private
       self.post.update_attribute(&quot;moderated_comments_count&quot;,new_count)
     end
   end
-  def increment_moderated_comments_counter
-    # Post.increment_count(:moderated_comments_count,self.post_id) if moderated
-    update_moderated_comment_count if moderated
-  end
+
   def decrement_moderated_comments_counter
-    # Post.decrement_count(:moderated_comments_count,self.post_id) if moderated
     update_moderated_comment_count(-1) if moderated?
   end
 end</diff>
      <filename>app/models/comment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,17 +1,18 @@
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+sample_post_moderated_comment:
+  moderated: true
+  author: Author 
+  body: &lt;p&gt;Templates are &lt;strong&gt;funky&lt;/strong&gt;.&lt;/p&gt;
+  body_raw: Templates are *funky*.
+  post: sample_post
+  author_email: &quot;&quot;
+  author_site: &quot;&quot;
 
-one:
-  post_id: 1
-  author: MyString
-  author_email: MyString
+sample_post_unmoderated_comment:
   moderated: false
-  body: MyText
-  body_raw: MyText
+  author: Author
+  body: &lt;p&gt;Templates are &lt;strong&gt;funky&lt;/strong&gt;.&lt;/p&gt;
+  body_raw: Templates are *funky*.
+  post: sample_post
+  author_email: &quot;&quot;
+  author_site: &quot;&quot;
 
-two:
-  post_id: 1
-  author: MyString
-  author_email: MyString
-  moderated: false
-  body: MyText
-  body_raw: MyText</diff>
      <filename>test/fixtures/comments.yml</filename>
    </modified>
    <modified>
      <diff>@@ -3,9 +3,9 @@
 one:
   title: MyString
   body: MyText
-  has_attachment: false
+  attachment: false
 
 two:
   title: MyString
   body: MyText
-  has_attachment: false
+  attachment: false</diff>
      <filename>test/fixtures/pages.yml</filename>
    </modified>
    <modified>
      <diff>@@ -35,3 +35,13 @@ non_unique_slug_non_unique_date2:
   body: MyText
   body_raw: MyText
 
+sample_post:
+  slug: new-rails-234-post
+  category: 
+  body: &lt;p&gt;&lt;em&gt;This&lt;/em&gt; is a &lt;strong&gt;test&lt;/strong&gt; of Rails 2.3.4&lt;/p&gt;
+  body_raw: _This_ is a *test* of Rails 2.3.4
+  title: New Rails 2.3.4 Post
+  closed: false
+  published: true
+  moderated_comments_count: 1
+</diff>
      <filename>test/fixtures/posts.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,45 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class CommentTest &lt; ActiveSupport::TestCase
-  # Replace this with your real tests.
-  def test_truth
-    assert true
+
+  def test_moderated
+    post = posts(:sample_post)
+    assert post.comments.moderated.include?(comments(:sample_post_moderated_comment))
+    assert !post.comments.moderated.any?{|c| c.moderated == false}
+  end
+
+  def test_unmoderated
+    post = posts(:sample_post)
+    assert post.comments.unmoderated.include?(comments(:sample_post_unmoderated_comment))
+    assert !post.comments.unmoderated.any?{|c| c.moderated == true}
+  end
+
+  def test_moderated
+    post = posts(:sample_post)
+    comment = comments(:sample_post_unmoderated_comment)
+
+    assert_equal false, comment.moderated?
+    comment.moderate
+    assert comment.moderated?
+  end
+
+  def test_moderation_increments_comment_counter
+    post = posts(:sample_post)
+    comment = comments(:sample_post_unmoderated_comment)
+
+    before = post.moderated_comments_count
+    comment.moderate
+    post.reload
+    assert_equal before + 1, post.moderated_comments_count
+  end
+
+  def test_destorying_comment_decrements_comment_counter
+    post = posts(:sample_post)
+    comment = comments(:sample_post_moderated_comment)
+
+    before = post.moderated_comments_count
+    comment.destroy
+    post.reload
+    assert_equal before - 1, post.moderated_comments_count
   end
 end</diff>
      <filename>test/unit/comment_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,6 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class PostTest &lt; ActiveSupport::TestCase
-  fixtures :posts
 
   def test_one_post_matching_permalink
     post = posts(:unique_slug)</diff>
      <filename>test/unit/post_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,9 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
-class UserTest &lt; Test::Unit::TestCase
+class UserTest &lt; ActiveSupport::TestCase
   # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead.
   # Then, you can remove it from this and the functional test.
   include AuthenticatedTestHelper
-  fixtures :users
 
   def test_should_create_user
     assert_difference 'User.count' do</diff>
      <filename>test/unit/user_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>918ec2b14bc65e3f4a1ab72e896793866200a142</id>
    </parent>
  </parents>
  <author>
    <name>mrchucho</name>
    <email>mrchucho@mrchucho.net</email>
  </author>
  <url>http://github.com/mrchucho/bbot/commit/30331424d9beb381e6ab22e904a30aeb077435c7</url>
  <id>30331424d9beb381e6ab22e904a30aeb077435c7</id>
  <committed-date>2009-10-09T08:54:52-07:00</committed-date>
  <authored-date>2009-10-09T08:54:52-07:00</authored-date>
  <message>Replacing some custom finders with named_scope. Added/Updated Unit Tests.</message>
  <tree>75d8d12fe4a2112bc8fccc55a3c35cd18282219c</tree>
  <committer>
    <name>mrchucho</name>
    <email>mrchucho@mrchucho.net</email>
  </committer>
</commit>
