diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 64a00becd89114bf5dd8446eb301fe25be600b41..f024e791c32fc691d9354e36e076f201ee179da9 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -39,6 +39,7 @@ class PeopleController < ApplicationController end @posts = current_user.visible_posts(:person_id => @person.id, :_type => "StatusMessage").paginate :page => params[:page], :order => 'created_at DESC' + @post_hashes = hashes_for_posts @posts respond_with @person, :locals => {:post_type => :all} else @@ -100,6 +101,21 @@ class PeopleController < ApplicationController end private + def hashes_for_posts posts + comment_hash = Comment.hash_from_post_ids posts.map{|p| p.id} + person_hash = Person.from_post_comment_hash comment_hash + + posts.map do |post| + {:post => post, + :person => @person, + :comments => comment_hash[post.id].map do |comment| + {:comment => comment, + :person => person_hash[comment.person_id], + } + end, + } + end + end def webfinger(account, opts = {}) finger = EMWebfinger.new(account) finger.on_person do |response| diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index 3f0e8ec318280f9295993750bd56124fcf69f5b6..27ac84168b5742c0e11ee15025553845c7ad201a 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -26,7 +26,7 @@ -if @post_type == :photos = render 'photos/index', :photos => @posts - else - = render 'shared/stream', :posts => @posts + = render 'shared/stream', :posts => @post_hashes = will_paginate @posts - else diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index d3b5a909f1679a694cf192802367097e222375e8..0824652dcb8515404fbc1c9569ffd1fbaaa29dcd 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -57,6 +57,19 @@ describe PeopleController do response.should be_success end + it 'renders with a post' do + user.post :status_message, :message => 'test more', :to => aspect.id + get :show, :id => user.person.id + response.should be_success + end + + it 'renders with a post' do + message = user.post :status_message, :message => 'test more', :to => aspect.id + user.comment 'I mean it', :on => message + get :show, :id => user.person.id + response.should be_success + end + it "redirects on an invalid id" do get :show, :id => 'delicious' response.should redirect_to people_path