diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index d17ac16f3..f883ee1e0 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -9,7 +9,7 @@ class AspectsController < ApplicationController respond_to :json, :only => :show def index - @posts = current_user.visible_posts(:_type => "StatusMessage").paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' + @posts = current_user.raw_visible_posts.find_all_by__type("StatusMessage", :order => 'updated_at desc').paginate :page => params[:page], :per_page => 15 @post_hashes = hashes_for_posts @posts @aspect_hashes = hashes_for_aspects @aspects.all, @contacts @aspect = :all @@ -62,7 +62,7 @@ class AspectsController < ApplicationController @aspect_contacts = @aspect.contacts @aspect_contacts_count = @aspect_contacts.count - @posts = @aspect.posts.find_all_by__type("StatusMessage", :order => 'created_at desc').paginate :page => params[:page], :per_page => 15 + @posts = @aspect.posts.find_all_by__type("StatusMessage", :order => 'updated_at desc').paginate :page => params[:page], :per_page => 15 @post_hashes = hashes_for_posts @posts @post_count = @posts.count diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 0e28c3fb8..8ed981cc4 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -11,7 +11,7 @@ class PeopleController < ApplicationController def index @aspect = :search - @people = Person.search(params[:q]).paginate :page => params[:page], :per_page => 25, :order => 'created_at DESC' + @people = Person.search(params[:q]).paginate :page => params[:page], :per_page => 25, :order => 'updated_at DESC' @requests = Request.all(:to_id.in => @people.map{|p| p.id}) #only do it if it is an email address @@ -39,7 +39,7 @@ class PeopleController < ApplicationController @aspects_with_person = @contact.aspects end - @posts = current_user.visible_posts(:person_id => @person.id, :_type => "StatusMessage").paginate :page => params[:page], :order => 'created_at DESC' + @posts = current_user.visible_posts(:person_id => @person.id, :_type => "StatusMessage").paginate :page => params[:page], :order => 'updated_at DESC' @post_hashes = hashes_for_posts @posts respond_with @person, :locals => {:post_type => :all} diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index b75aa24d1..fcf7c1b55 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -21,7 +21,7 @@ class PhotosController < ApplicationController @aspects_with_person = @contact.aspects end - @posts = current_user.raw_visible_posts.all(:_type => 'Photo', :person_id => @person.id, :order => 'created_at DESC').paginate :page => params[:page], :order => 'created_at DESC' + @posts = current_user.raw_visible_posts.all(:_type => 'Photo', :person_id => @person.id, :order => 'updated_at DESC').paginate :page => params[:page], :order => 'created_at DESC' render 'people/show' diff --git a/app/models/comment.rb b/app/models/comment.rb index 524fcbf05..edde70cb4 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -36,6 +36,11 @@ class Comment validates_presence_of :text, :diaspora_handle, :post validates_with HandleValidator + after_create do + #save the parent post to update updated_at timestamp + post.save + end + before_save do get_youtube_title text end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index d4b12ce95..c6fa02e92 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -70,6 +70,15 @@ describe Comment do user2.comment "sup dog", :on => @status @status.reload.comments.first.text.should == "sup dog" end + + it "updates updated_at of parent post on creation" do + hash = @status.to_mongo + hash[:updated_at] = (Time.now - 20).to_s + @status.collection.save(hash) + user2.comment "sup dog", :on => @status + @status.reload.updated_at.should == @status.comments.first.created_at + end + end it 'should not send out comments when we have no people' do