<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,16 +4,7 @@ class GroupsController &lt; ApplicationController
   #uses_tiny_mce :options =&gt; tiny_mce_options, :only =&gt; [ :new,:create, :update, :edit ]
   
   def index
-    @groups = Group.all
-    respond_to do |format|
-      format.html { 
-        @posts = Post.sorted_by_commented_at.paginate(:page =&gt; params[:page], :per_page =&gt; 15) 
-      }
-      format.rss { 
-        @posts = Post.sorted_by_commented_at.limit_to(15)
-        render :layout =&gt; false 
-      }
-    end
+    @groups = Group.order_by_contributed_at
   end
   
   def show</diff>
      <filename>app/controllers/groups_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ class Group &lt; ActiveRecord::Base
   alias_attribute :category, :group_category
   alias_attribute :images, :post_images
   
-  named_scope :order_by_contributed_at, lambda {  { :order =&gt; &quot;contributed_at DESC&quot; } }
+  named_scope :order_by_contributed_at, lambda {  { :conditions=&gt;&quot;contributed_at is not NULL&quot;, :order =&gt; &quot;contributed_at DESC&quot; } }
 
   def to_param
     name</diff>
      <filename>app/models/group.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,8 @@ class Post &lt; ActiveRecord::Base
   validates_presence_of :video, :if =&gt; :specifying_video
   validate :must_have_attachment
   #validates_tiny_mce_presence_of :detail, :unless =&gt; :specifying_video
+  validates_presence_of :group
+  validates_associated :group
   
   belongs_to :group
   
@@ -33,6 +35,11 @@ class Post &lt; ActiveRecord::Base
     post.commented_at = post.created_at
   end
   
+  before_create do |post|
+    post.group.contributed_at = Time.now
+    post.group.save!
+  end
+  
   def brief
     truncate_html_text(detail)
   end</diff>
      <filename>app/models/post.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,8 +4,10 @@ studio1:
   desc: Studio one is such a cool place
   home_page: MyString
   contributed_at: &lt;%= 1.day.ago %&gt;
+  group_category: other 
 
 studio3:
   name: Studio Free
   desc: We love ourselves
   home_page: MyString
+  group_category: other </diff>
      <filename>test/fixtures/groups.yml</filename>
    </modified>
    <modified>
      <diff>@@ -60,7 +60,6 @@ class GroupsTest &lt; ActionController::IntegrationTest
       assert_has_links [&quot;/groups/Studio%201/edit&quot;]
       assert_select 'a[href=MyString]'
       get_ok &quot;/groups/Studio%201/edit&quot;
-      view
       submit_form do |form|
         form.group.home_page = 'http://somewhereelse'
       end</diff>
      <filename>test/integration/groups_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,28 +1,29 @@
 require 'test_helper'
 
 class GroupTest &lt; ActiveSupport::TestCase
-  should &quot;should updated_at when new post&quot; do
+  context &quot;a group&quot; do
+    should &quot;should update contributed_at when new post&quot; do
     group = Group.find(groups(:studio1).id)
-    assert group.updated_at &lt; (Time.now+ 10)
+    assert group.contributed_at &lt; (Time.now- 10)
     
     group.posts.new(:title=&gt;'some', :detail=&gt;'some').save!
     
     group = Group.find(groups(:studio1).id)
-    assert group.updated_at &gt; (Time.now + 10)
+    assert group.contributed_at &gt; (Time.now - 10)
   end
-  
+  end 
   context &quot;Group class&quot; do
     should &quot;be able to find by contributed_at&quot; do
       groups = Group.order_by_contributed_at
       groups = groups.all # make sure we get the array!
       assert_equal 1, groups.size
-      assert_equal group(:studio1).id,groups[0]
+      assert_equal groups(:studio1).id,groups[0].id
       
       Group.find(groups(:studio3).id).posts.new(:title=&gt;'some', :detail=&gt;'some').save!
-          groups = Group.order_by_contributed_at
+      groups = Group.order_by_contributed_at
       groups = groups.all # make sure we get the array!
       assert_equal 2, groups.size
-      assert_equal group(:studio3).id,groups[0]
+      assert_equal groups(:studio3).id,groups[0].id
     end
   end
   </diff>
      <filename>test/unit/group_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../test_helper'
 class PostTest &lt; ActiveSupport::TestCase
 
   should &quot;ensure that the subscriber list for a post is unique&quot; do
-    post = Post.new
+    post = new_post
     assert_equal([], post.subscribers)
     
     duff = users(:duff)
@@ -22,10 +22,10 @@ class PostTest &lt; ActiveSupport::TestCase
   
   context &quot;video_embed_tags&quot; do
   should &quot;should calculate ok for youtube&quot; do
-    post = Post.new
+    post = new_post
     assert_nil(post.video_embed_tags)
     
-    post = Post.new(:video =&gt; &quot;     &quot;)
+    post = new_post(:video =&gt; &quot;     &quot;)
     assert_nil(post.video_embed_tags)
     
     post.video = %Q{&lt;object width=&quot;425&quot; height=&quot;344&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/yCM_wQy4YVg&amp;hl=en&amp;fs=1&amp;color1=0xe1600f&amp;color2=0xfebd01&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/yCM_wQy4YVg&amp;hl=en&amp;fs=1&amp;color1=0xe1600f&amp;color2=0xfebd01&quot; type=&quot;application/x-shockwave-flash&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot; width=&quot;425&quot; height=&quot;344&quot;&gt;&lt;/embed&gt;&lt;/object&gt;}
@@ -66,19 +66,19 @@ class PostTest &lt; ActiveSupport::TestCase
   end
 
   should &quot;allow embed tag blip.tv to pass through&quot; do
-    post = Post.new
+    post = new_post
     post.video = %Q{&lt;embed src=&quot;http://blip.tv/play/lG3hz1eBolM&quot; type=&quot;application/x-shockwave-flash&quot; width=&quot;1024&quot; height=&quot;798&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot;&gt;&lt;/embed&gt;}
     assert_equal(post.video, post.video_embed_tags)
   end
 
   should &quot;currently I think allow for aritrary object tag to pass through&quot; do
-        post = Post.new
+        post = new_post
         post.video = %Q{&lt;object &gt;some stuff&lt;/object&gt;}
     assert_equal(post.video, post.video_embed_tags)
   end
   
   should &quot;convert http urls to links&quot; do
-      post = Post.new
+      post = new_post
       link = %Q{http://someurlorother.com/wherever}
       post.video = link
       assert(post.video_embed_tags.include?(%Q{&lt;a href=&quot;#{link}&quot; rel=&quot;nofollow&quot;&gt;#{link}&lt;/a&gt;}))
@@ -86,7 +86,7 @@ class PostTest &lt; ActiveSupport::TestCase
  end
  
   should &quot;require video appropriately&quot; do
-    post = Post.new(:title =&gt; &quot;Whatever&quot;, :detail =&gt; &quot;Whatever&quot;)
+    post = new_post(:title =&gt; &quot;Whatever&quot;, :detail =&gt; &quot;Whatever&quot;)
     assert post.valid?
     
     post.specifying_video = true
@@ -103,13 +103,13 @@ class PostTest &lt; ActiveSupport::TestCase
 
   
   should &quot;calculate preview_image for video&quot; do
-    post = Post.new
+    post = new_post
     expectedPreviewImage = nil 
     assert_equal(expectedPreviewImage, post.preview_image)
   end
   
   should &quot;calculate preview_image_src for video&quot; do
-    post = Post.new
+    post = new_post
     expectedPreviewImage = %Q{http://img.youtube.com/vi/FG2PUZoukfA/2.jpg} 
 
     post.video = %Q{http://youtube.com/watch?v=FG2PUZoukfA}
@@ -123,7 +123,7 @@ class PostTest &lt; ActiveSupport::TestCase
   end
   
    should &quot;initialize date fields correctly&quot; do
-    post = Post.new(:title =&gt; &quot;Whatever&quot;, :detail =&gt; &quot;Whatever&quot;)
+    post = new_post(:title =&gt; &quot;Whatever&quot;, :detail =&gt; &quot;Whatever&quot;)
     assert post.valid?
     post.save!
     assert !post.created_at.nil?, &quot;expected created at not to be nil&quot;
@@ -140,4 +140,8 @@ class PostTest &lt; ActiveSupport::TestCase
 #     assert post.has_contributed?(users(:duff))
 #  end
 #  end
+
+  def new_post *args
+    groups(:studio1).posts.new *args
+  end
 end</diff>
      <filename>test/unit/post_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,7 @@ class TagTest &lt; ActiveSupport::TestCase
   
   should &quot;handle basic relationship with post&quot; do
     tag = Tag.create!(:name =&gt; &quot;Cool&quot;)
-    post = Post.create!(:title =&gt; &quot;My Post&quot;, :detail =&gt; &quot;Here it be&quot;)
+    post = create_post!(:title =&gt; &quot;My Post&quot;, :detail =&gt; &quot;Here it be&quot;)
     
     assert_equal([], tag.posts)
     assert_equal([], post.tags)
@@ -21,7 +21,7 @@ class TagTest &lt; ActiveSupport::TestCase
     assert_equal([tag], post.tags)
     assert_equal([post], tag.posts)
     
-    another_post = Post.create!(:title =&gt; &quot;My Second Post&quot;, :detail =&gt; &quot;Here it be again&quot;)
+    another_post = create_post!(:title =&gt; &quot;My Second Post&quot;, :detail =&gt; &quot;Here it be again&quot;)
     another_tag = Tag.create!(:name =&gt; &quot;Really Cool&quot;)
     
     tag.posts &lt;&lt; another_post
@@ -104,4 +104,8 @@ class TagTest &lt; ActiveSupport::TestCase
     assert_equal ['two','one','one','one'], gotCss
     
   end
+  
+  def create_post! *args
+    groups(:studio1).posts.create! *args
+  end
 end</diff>
      <filename>test/unit/tag_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c970495eb8b44babb6e55080d66a396291f04c05</id>
    </parent>
  </parents>
  <author>
    <name>Tim Diggins</name>
    <email>tim@red56.co.uk</email>
  </author>
  <url>http://github.com/red56/the-connected-website/commit/31df81af1c28ce26d5039d64f5dd61e318ce8fec</url>
  <id>31df81af1c28ce26d5039d64f5dd61e318ce8fec</id>
  <committed-date>2009-06-09T04:30:03-07:00</committed-date>
  <authored-date>2009-06-09T04:30:03-07:00</authored-date>
  <message>http://nokahuna.com/projects/5943/tasks/85 list groups by contributed_at</message>
  <tree>6323fea0ecc691ef5a9736ee8ee687c489f520c1</tree>
  <committer>
    <name>Tim Diggins</name>
    <email>tim@red56.co.uk</email>
  </committer>
</commit>
