<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,10 +1,11 @@
 class Forum &lt; ActiveRecord::Base
   acts_as_list
+  
   has_permalink :name, :slug
   
   named_scope :ordered, {:order =&gt; &quot;#{Forum.table_name}.position ASC&quot;}
   
-  has_many :topics, :order =&gt; &quot;#{Topic.table_name}.sticky DESC, #{Topic.table_name}.last_updated_at DESC&quot;, :dependent =&gt; :delete_all
+  has_many :topics, :order =&gt; &quot;#{Topic.table_name}.sticky DESC, #{Topic.table_name}.last_updated_at DESC&quot;, :dependent =&gt; :destroy
   
   validates_presence_of :name
   </diff>
      <filename>app/models/forum.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,21 +1,42 @@
+module Posts
+  module Callbacks
+    def self.included(base)
+      base.send :include, Posts::Callbacks::InstanceMethods
+      base.before_validation_on_create :set_forum_from_topic
+    end
+    
+    module InstanceMethods
+      protected
+      
+      def set_forum_from_topic
+        self.forum = self.topic.forum
+      end
+    end
+  end
+  module Validations
+    def self.included(base)
+      base.send :include, Posts::Validations::InstanceMethods
+      base.validate :topic_is_not_locked, :if =&gt; lambda {|post| post.topic &amp;&amp; post.topic.posts_count &gt; 0}
+      base.validates_presence_of :author_id, :forum_id, :topic_id, :body
+    end
+    
+    module InstanceMethods
+      protected
+      
+      def topic_is_not_locked
+        errors.add(:topic_id, &quot;is locked&quot;) if self.topic.locked?
+      end
+    end
+  end
+end
+
 class Post &lt; ActiveRecord::Base
+  include Posts::Callbacks
+  include Posts::Validations
+  
   belongs_to :author, :class_name =&gt; &quot;User&quot;, :foreign_key =&gt; :author_id, :counter_cache =&gt; true
   belongs_to :forum, :counter_cache =&gt; true
   belongs_to :topic, :counter_cache =&gt; true
   
-  before_validation_on_create :set_forum_from_topic
-  validate :topic_is_not_locked, :if =&gt; lambda {|post| post.topic &amp;&amp; post.topic.posts_count &gt; 0}
-  validates_presence_of :author_id, :forum_id, :topic_id, :body
-  
   delegate :name, :to =&gt; :forum, :prefix =&gt; true
-  
-  protected
-  
-  def set_forum_from_topic
-    self.forum = self.topic.forum
-  end
-  
-  def topic_is_not_locked
-    errors.add(:topic_id, &quot;is locked&quot;) if self.topic.locked?
-  end
 end
\ No newline at end of file</diff>
      <filename>app/models/post.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,37 @@
+module Topics
+  module Callbacks
+    def self.included(base)
+      base.send :include, Topics::Callbacks::InstanceMethods
+      base.after_create :create_initial_post
+    end
+    
+    module InstanceMethods
+      protected
+      def create_initial_post
+        self.posts.create(:author =&gt; self.creator, :body =&gt; self.body)
+      end
+    end
+  end
+  module Validations
+    def self.included(base)
+      base.validates_presence_of :title, :creator_id, :forum_id
+      base.validates_presence_of :body, :on =&gt; :create
+    end
+  end
+  module NamedScopes
+    def self.included(base)
+      base.named_scope :sticky, { :conditions =&gt; {:sticky =&gt; true} }
+      base.named_scope :not_sticky, { :conditions =&gt; {:sticky =&gt; false} }
+    end
+  end
+end
+
 class Topic &lt; ActiveRecord::Base
-  has_permalink :title, :slug, :scope =&gt; :forum_id
+  include Topics::Callbacks
+  include Topics::Validations
+  include Topics::NamedScopes
   
-  named_scope :sticky, { :conditions =&gt; {:sticky =&gt; true} }
-  named_scope :not_sticky, { :conditions =&gt; {:sticky =&gt; false}}
+  has_permalink :title, :slug, :scope =&gt; :forum_id
   
   belongs_to  :forum, :counter_cache =&gt; true
   belongs_to  :creator, :class_name =&gt; &quot;User&quot;, :foreign_key =&gt; :creator_id
@@ -12,13 +41,7 @@ class Topic &lt; ActiveRecord::Base
   belongs_to  :last_post, :class_name =&gt; &quot;Post&quot;, :foreign_key =&gt; :last_post_id
   belongs_to  :last_user, :class_name =&gt; &quot;User&quot;, :foreign_key =&gt; :last_user_id
   
-  validates_presence_of :title, :creator_id, :forum_id
-  validates_presence_of :body, :on =&gt; :create
-  
-  after_create :create_initial_post
-  
   attr_accessible :title, :body, :forum, :creator, :sticky, :locked
-  
   attr_accessor :body
   
   def view!
@@ -28,10 +51,4 @@ class Topic &lt; ActiveRecord::Base
   def to_param
     self.slug
   end
-  
-  protected
-  
-  def create_initial_post
-    self.posts.create(:author =&gt; self.creator, :body =&gt; self.body)
-  end
 end</diff>
      <filename>app/models/topic.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,11 +8,11 @@ class ForumPresenter
   end
   
   def can_be_edited_by_current_user?
-    !!(@current_user &amp;&amp; @current_user.has_privilege?(:admin))
+    is_current_user_admin?
   end
   
   def can_be_deleted_by_current_user?
-    false
+    is_current_user_admin?
   end
   
   def can_topic_be_created_by_current_user?
@@ -22,4 +22,10 @@ class ForumPresenter
   def method_missing(call, *args)
     @forum.send call, *args
   end
+  
+  private
+  
+  def is_current_user_admin?
+    !!(@current_user &amp;&amp; @current_user.has_privilege?(:admin))
+  end
 end
\ No newline at end of file</diff>
      <filename>app/presenters/forum_presenter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,8 +5,9 @@ class ForumsPresenter
   
   def initialize(options = {})
     options.assert_valid_keys(:forums, :current_user)
-    @forums = options[:forums] || Forum.ordered
     @current_user = options[:current_user]
+    @forums = options[:forums] || Forum.ordered
+    @forums = @forums.map {|forum| ForumPresenter.new(:forum =&gt; forum, :current_user =&gt; @current_user) }
   end
   
   def can_be_created_by_current_user?</diff>
      <filename>app/presenters/forums_presenter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,9 @@
     &lt;% forums.each do |forum| %&gt;
       &lt;% zebra_row :id =&gt; dom_id(forum), :class =&gt; (&quot;grabbable&quot; if forums.can_be_reordered_by_current_user?) do %&gt;
         &lt;td&gt;
-          &lt;span class=&quot;forum-title&quot;&gt;&lt;%= link_to forum.name, forum %&gt;&lt;/span&gt;&lt;br/&gt;
+          &lt;span class=&quot;forum-title&quot;&gt;&lt;%= link_to forum.name, forum %&gt;&lt;/span&gt;
+          &lt;%= link_to &quot;Delete&quot;, forum, :method =&gt; :delete, :confirm =&gt; &quot;Are you sure?&quot; if forum.can_be_deleted_by_current_user? %&gt;
+          &lt;br/&gt;
           &lt;%= textilize forum.description %&gt;
         &lt;/td&gt;
         &lt;td class=&quot;number&quot;&gt;&lt;%= forum.topics_count %&gt;&lt;/td&gt;</diff>
      <filename>app/views/forums/_recordset.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -2,11 +2,15 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
 
 describe Post do
   before(:each) do
-    @valid_attributes = {
-    }
-  end
-
-  it &quot;should create a new instance given valid attributes&quot; do
-    Post.create!(@valid_attributes)
+    @post = Generate.post
   end
+  
+  it { @post.should be_valid }
+  it { @post.should belong_to(:forum) }
+  it { @post.should belong_to(:topic) }
+  it { @post.should belong_to(:author) }
+  it { @post.should validate_presence_of(:author_id) }
+  it { @post.should validate_presence_of(:forum_id) }
+  it { @post.should validate_presence_of(:topic_id) }
+  it { @post.should validate_presence_of(:body) }
 end</diff>
      <filename>spec/models/post_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,8 +9,8 @@ class Generate
   
   def self.admin_user(attributes = {})
     Generate.user(attributes.reverse_merge({
-      :role =&gt; &quot;admin&quot;,
-      :privilege =&gt; &quot;admin&quot;
+      :role       =&gt; &quot;admin&quot;,
+      :privilege  =&gt; &quot;admin&quot;
     }))
   end
   
@@ -20,13 +20,13 @@ class Generate
     key = ActiveSupport::SecureRandom.hex(16)
     
     user = User.new(attributes.reverse_merge({
-      :first_name =&gt; &quot;John&quot;,
-      :last_name =&gt; &quot;Doe&quot;,
-      :password =&gt; &quot;password&quot;,
-      :password_confirmation =&gt; &quot;password&quot;,
-      :active =&gt; true,
-      :username =&gt; key,
-      :email_address =&gt; &quot;#{key}@test.com&quot;}))
+      :first_name             =&gt; &quot;John&quot;,
+      :last_name              =&gt; &quot;Doe&quot;,
+      :password               =&gt; &quot;password&quot;,
+      :password_confirmation  =&gt; &quot;password&quot;,
+      :active                 =&gt; true,
+      :username               =&gt; key,
+      :email_address          =&gt; &quot;#{key}@test.com&quot;}))
     role = Role.find_or_create_by_name(default_role)
     privs = []
     default_privileges.each {|p| privs &lt;&lt; Privilege.find_or_create_by_name(p)}
@@ -39,12 +39,22 @@ class Generate
   
   def self.topic(attributes = {})
     topic = Topic.new(attributes.reverse_merge({
-      :body =&gt; &quot;Body text&quot;,
-      :forum =&gt; Generate.forum,
-      :creator =&gt; Generate.user,
-      :title =&gt; &quot;Random Title&quot;
+      :body     =&gt; &quot;Body text&quot;,
+      :forum    =&gt; Generate.forum,
+      :creator  =&gt; Generate.user,
+      :title    =&gt; &quot;Random Title&quot;
     }))
     topic.save!
     topic
   end
+  
+  def self.post(attributes = {})
+    post = Post.new(attributes.reverse_merge({
+      :body   =&gt; &quot;Test post&quot;,
+      :author =&gt; (author = Generate.user),
+      :topic  =&gt; Generate.topic(:creator =&gt; author)
+    }))
+    post.save!
+    post
+  end
 end
\ No newline at end of file</diff>
      <filename>spec/spec_helpers/generate.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>README</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>631cc5ddabba7267b513eb5f4a36084a8522e4ed</id>
    </parent>
  </parents>
  <author>
    <name>Joshua Clayton</name>
    <email>jclayton@fusionary.com</email>
  </author>
  <url>http://github.com/joshuaclayton/fuzzy-monster/commit/dd7a0751752aa3547d74c770ac16234746c8a7ed</url>
  <id>dd7a0751752aa3547d74c770ac16234746c8a7ed</id>
  <committed-date>2008-11-30T19:05:08-08:00</committed-date>
  <authored-date>2008-11-30T19:05:08-08:00</authored-date>
  <message>Updated models to be more modular, updated model factory and a basic post specs</message>
  <tree>47d963ddda3df7d0ff4b513980599439075b41fe</tree>
  <committer>
    <name>Joshua Clayton</name>
    <email>jclayton@fusionary.com</email>
  </committer>
</commit>
