pagination works on aspects#show
This commit is contained in:
parent
a0f9fb35f3
commit
abae16472d
2 changed files with 23 additions and 1 deletions
|
|
@ -57,7 +57,7 @@ class AspectsController < ApplicationController
|
|||
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||
else
|
||||
@aspect_contacts = @aspect.contacts
|
||||
@posts = @aspect.posts.find_all_by__type("StatusMessage", :order => 'created_at desc').paginate :per_page => 15
|
||||
@posts = @aspect.posts.find_all_by__type("StatusMessage", :order => 'created_at desc').paginate :page => params[:page], :per_page => 15
|
||||
respond_with @aspect
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -54,6 +54,28 @@ describe AspectsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#show" do
|
||||
it "succeeds" do
|
||||
get :show, 'id' => @aspect.id.to_s
|
||||
response.should be_success
|
||||
end
|
||||
it "assigns aspect, aspect_contacts, and posts" do
|
||||
get :show, 'id' => @aspect.id.to_s
|
||||
assigns(:aspect).should == @aspect
|
||||
assigns(:aspect_contacts).should == @aspect.contacts
|
||||
assigns(:posts).should == []
|
||||
end
|
||||
it "paginates" do
|
||||
16.times { |i| @user2.post(:status_message, :to => @aspect2.id, :message => "hi #{i}") }
|
||||
|
||||
get :show, 'id' => @aspect.id.to_s
|
||||
assigns(:posts).count.should == 15
|
||||
|
||||
get :show, 'id' => @aspect.id.to_s, 'page' => '2'
|
||||
assigns(:posts).count.should == 1
|
||||
end
|
||||
end
|
||||
|
||||
describe "#create" do
|
||||
describe "with valid params" do
|
||||
it "creates an aspect" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue