Fix people#show sort order
This commit is contained in:
parent
30c30e0d3e
commit
85993a694e
2 changed files with 20 additions and 9 deletions
|
|
@ -97,10 +97,11 @@ class PeopleController < ApplicationController
|
||||||
@posts = current_user.posts_from(@person).where(:type => "StatusMessage").includes(:comments).limit(15).offset(15*(params[:page]-1))
|
@posts = current_user.posts_from(@person).where(:type => "StatusMessage").includes(:comments).limit(15).offset(15*(params[:page]-1))
|
||||||
else
|
else
|
||||||
@commenting_disabled = true
|
@commenting_disabled = true
|
||||||
@posts = @person.posts.where(:type => "StatusMessage", :public => true).includes(:comments).limit(15).offset(15*(params[:page]-1))
|
@posts = @person.posts.where(:type => "StatusMessage", :public => true).includes(:comments).limit(15).offset(15*(params[:page]-1)).order('posts.created_at DESC')
|
||||||
end
|
end
|
||||||
|
|
||||||
@posts = PostsFake.new(@posts)
|
@posts = PostsFake.new(@posts)
|
||||||
|
|
||||||
if params[:only_posts]
|
if params[:only_posts]
|
||||||
render :partial => 'shared/stream', :locals => {:posts => @posts}
|
render :partial => 'shared/stream', :locals => {:posts => @posts}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -154,16 +154,26 @@ describe PeopleController do
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it "assigns only public posts" do
|
context 'with posts' do
|
||||||
public_posts = []
|
before do
|
||||||
public_posts << bob.post(:status_message, :text => "first public ", :to => bob.aspects[0].id, :public => true)
|
@public_posts = []
|
||||||
|
@public_posts << bob.post(:status_message, :text => "first public ", :to => bob.aspects[0].id, :public => true)
|
||||||
bob.post(:status_message, :text => "to an aspect @user is not in", :to => bob.aspects[1].id)
|
bob.post(:status_message, :text => "to an aspect @user is not in", :to => bob.aspects[1].id)
|
||||||
bob.post(:status_message, :text => "to all aspects", :to => 'all')
|
bob.post(:status_message, :text => "to all aspects", :to => 'all')
|
||||||
public_posts << bob.post(:status_message, :text => "public", :to => 'all', :public => true)
|
@public_posts << bob.post(:status_message, :text => "public", :to => 'all', :public => true)
|
||||||
|
@public_posts.first.created_at -= 1000
|
||||||
|
@public_posts.first.save
|
||||||
|
end
|
||||||
|
|
||||||
|
it "assigns only public posts" do
|
||||||
get :show, :id => @person.id
|
get :show, :id => @person.id
|
||||||
|
assigns[:posts].models.should =~ @public_posts
|
||||||
|
end
|
||||||
|
|
||||||
assigns[:posts].models.should =~ public_posts
|
it 'is sorted by created_at desc' do
|
||||||
|
get :show, :id => @person.id
|
||||||
|
assigns[:posts].models.should == @public_posts.sort_by{|p| p.created_at}.reverse
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'throws 404 if the person is remote' do
|
it 'throws 404 if the person is remote' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue