diff --git a/Changelog.md b/Changelog.md index 4f96202ce..70afeda23 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ * Do not render mobile photo view for none-existing photos [#4194](https://github.com/diaspora/diaspora/issues/4194) * Render markdown content for prettier email subjects and titles [#4182](https://github.com/diaspora/diaspora/issues/4182) * Disable invite button after sending invite [#4173](https://github.com/diaspora/diaspora/issues/4173) +* Fix pagination for people list on the tag stream page [#4245](https://github.com/diaspora/diaspora/pull/4245) ## Features * Admin: add option to find users under 13 (COPPA) [#4252](https://github.com/diaspora/diaspora/pull/4252) diff --git a/app/views/people/_index.html.haml b/app/views/people/_index.html.haml index a1afcd7f5..0c90823e6 100644 --- a/app/views/people/_index.html.haml +++ b/app/views/people/_index.html.haml @@ -8,4 +8,4 @@ %span.from = person_link(person, :class => "hovercardable") - = will_paginate people, :inner_window => 3, :params => {:controller => 'people', :action => 'tag_index'} + = will_paginate people, :inner_window => 3 diff --git a/lib/stream/tag.rb b/lib/stream/tag.rb index a1a096bed..bd4ceabb6 100644 --- a/lib/stream/tag.rb +++ b/lib/stream/tag.rb @@ -3,11 +3,12 @@ # the COPYRIGHT file. class Stream::Tag < Stream::Base - attr_accessor :tag_name, :people_page + attr_accessor :tag_name, :people_page , :people_per_page def initialize(user, tag_name, opts={}) self.tag_name = tag_name self.people_page = opts[:page] || 1 + self.people_per_page = 15 super(user, opts) end @@ -24,7 +25,7 @@ class Stream::Tag < Stream::Base end def tagged_people - @people ||= ::Person.profile_tagged_with(tag_name).paginate(:page => people_page, :per_page => 15) + @people ||= ::Person.profile_tagged_with(tag_name).paginate(:page => people_page, :per_page => people_per_page) end def tagged_people_count diff --git a/spec/integration/tag_people_spec.rb b/spec/integration/tag_people_spec.rb new file mode 100644 index 000000000..049ef9375 --- /dev/null +++ b/spec/integration/tag_people_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +describe TagsController, type: :controller do + describe 'will_paginate people on the tag page' do + let(:people) { (1..2).map { FactoryGirl.create(:person) } } + let(:tag) { "diaspora" } + + before do + Stream::Tag.any_instance.stub(people_per_page: 1) + Person.should_receive(:profile_tagged_with).with(/#{tag}/).twice.and_return(people) + end + + it 'paginates the people set' do + get "/tags/#{tag}" + + expect(response.status).to eq(200) + response.body.should match(/div class="pagination"/) + response.body.should match(/href="\/tags\/#{tag}\?page=2"/) + end + + it 'fetches the second page' do + get "/tags/#{tag}", page: 2 + + expect(response.status).to eq(200) + response.body.should match(/2<\/em>/) + end + end +end