diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index fc2e40006..04328b5fe 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -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 diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index c017d5554..ac78d930a 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -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