Commented-on posts bubble up to the top
This commit is contained in:
parent
8d853a88a3
commit
6da410079b
5 changed files with 19 additions and 5 deletions
|
|
@ -9,7 +9,7 @@ class AspectsController < ApplicationController
|
||||||
respond_to :json, :only => :show
|
respond_to :json, :only => :show
|
||||||
|
|
||||||
def index
|
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
|
@post_hashes = hashes_for_posts @posts
|
||||||
@aspect_hashes = hashes_for_aspects @aspects.all, @contacts
|
@aspect_hashes = hashes_for_aspects @aspects.all, @contacts
|
||||||
@aspect = :all
|
@aspect = :all
|
||||||
|
|
@ -62,7 +62,7 @@ class AspectsController < ApplicationController
|
||||||
@aspect_contacts = @aspect.contacts
|
@aspect_contacts = @aspect.contacts
|
||||||
@aspect_contacts_count = @aspect_contacts.count
|
@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_hashes = hashes_for_posts @posts
|
||||||
@post_count = @posts.count
|
@post_count = @posts.count
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class PeopleController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@aspect = :search
|
@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})
|
@requests = Request.all(:to_id.in => @people.map{|p| p.id})
|
||||||
|
|
||||||
#only do it if it is an email address
|
#only do it if it is an email address
|
||||||
|
|
@ -39,7 +39,7 @@ class PeopleController < ApplicationController
|
||||||
@aspects_with_person = @contact.aspects
|
@aspects_with_person = @contact.aspects
|
||||||
end
|
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
|
@post_hashes = hashes_for_posts @posts
|
||||||
respond_with @person, :locals => {:post_type => :all}
|
respond_with @person, :locals => {:post_type => :all}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class PhotosController < ApplicationController
|
||||||
@aspects_with_person = @contact.aspects
|
@aspects_with_person = @contact.aspects
|
||||||
end
|
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'
|
render 'people/show'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,11 @@ class Comment
|
||||||
validates_presence_of :text, :diaspora_handle, :post
|
validates_presence_of :text, :diaspora_handle, :post
|
||||||
validates_with HandleValidator
|
validates_with HandleValidator
|
||||||
|
|
||||||
|
after_create do
|
||||||
|
#save the parent post to update updated_at timestamp
|
||||||
|
post.save
|
||||||
|
end
|
||||||
|
|
||||||
before_save do
|
before_save do
|
||||||
get_youtube_title text
|
get_youtube_title text
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,15 @@ describe Comment do
|
||||||
user2.comment "sup dog", :on => @status
|
user2.comment "sup dog", :on => @status
|
||||||
@status.reload.comments.first.text.should == "sup dog"
|
@status.reload.comments.first.text.should == "sup dog"
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
it 'should not send out comments when we have no people' do
|
it 'should not send out comments when we have no people' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue