Improve User#posts_from

This commit is contained in:
Raphael 2011-01-17 13:12:26 -08:00
parent 79b613b0e5
commit 6eb0dfb43f
2 changed files with 2 additions and 1 deletions

View file

@ -72,7 +72,7 @@ module Diaspora
def posts_from(person) def posts_from(person)
asp = Aspect.arel_table asp = Aspect.arel_table
p = Post.arel_table p = Post.arel_table
Post.joins(:aspects).where( p[:public].eq(true).or(asp[:user_id].eq(self.id))).order("updated_at DESC") Post.includes(:aspects).where( p[:public].eq(true).or(asp[:user_id].eq(self.id))).order("posts.updated_at DESC")
end end
end end
end end

View file

@ -216,6 +216,7 @@ describe PeopleController do
status_message = user2.post(:status_message, :message => "hey there", :to => 'all', :public => true) status_message = user2.post(:status_message, :message => "hey there", :to => 'all', :public => true)
get :show, :id => user2.person.id get :show, :id => user2.person.id
assigns[:posts].should include status_message
response.body.should include status_message.message response.body.should include status_message.message
end end
end end