From 6eb0dfb43f6ccb20a6e241d06d46f866cdc4f75c Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 17 Jan 2011 13:12:26 -0800 Subject: [PATCH] Improve User#posts_from --- lib/diaspora/user/querying.rb | 2 +- spec/controllers/people_controller_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index 337afe6e6..ab0d68275 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -72,7 +72,7 @@ module Diaspora def posts_from(person) asp = Aspect.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 diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 67941ee3a..7d913f28c 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -216,6 +216,7 @@ describe PeopleController do status_message = user2.post(:status_message, :message => "hey there", :to => 'all', :public => true) get :show, :id => user2.person.id + assigns[:posts].should include status_message response.body.should include status_message.message end end