Fix pages after 1 on tag page

This commit is contained in:
Raphael Sofaer 2011-04-26 20:01:50 -07:00
parent 05d05046bb
commit b4e36878fe
6 changed files with 27 additions and 5 deletions

View file

@ -52,7 +52,11 @@ class TagsController < ApplicationController
end
@posts = @posts.tagged_with(params[:name])
@posts = @posts.includes(:comments, :photos).order('created_at DESC').limit(15).offset(15*(params[:page]-1))
max_time = params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now
@posts = @posts.where(StatusMessage.arel_table[:created_at].lt(max_time))
@posts = @posts.includes(:comments, :photos).order('posts.created_at DESC').limit(15)
@posts = PostsFake.new(@posts)
@commenting_disabled = true

View file

@ -1,4 +1,4 @@
#/ Copyright (c) 2010, Diaspora Inc. This file is
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.

View file

@ -0,0 +1,9 @@
# Copyright (c) 2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module TagsHelper
def next_page_path
tag_path(@tag, :max_time => @posts.last.send(session[:sort_order].to_sym).to_i)
end
end

View file

@ -344,5 +344,4 @@ class User < ActiveRecord::Base
mentioned_person.delete
end
end
end

View file

@ -23,7 +23,7 @@
- if @posts.length > 0
= render 'shared/stream', :posts => @posts
#pagination
=link_to(t('more'), tag_path(params[:name], :page => next_page), :class => 'paginate')
=link_to(t('more'), next_page_path, :class => 'paginate')
- else
= t('.nobody_talking', :tag => "##{params[:name]}")

View file

@ -25,3 +25,13 @@ Feature: infinite scroll
And I wait for the ajax to finish
And I wait for the ajax to finish
Then I should see 30 posts
Scenario: On a tag page
When I sign in as "bob@bob.bob"
And I am on the tag page for "seeded"
Then I should see 15 posts
When I scroll down
And I wait for the ajax to finish
And I wait for the ajax to finish
Then I should see 30 posts