Skip to content

Commit df7728e

Browse files
committed
Merge pull request #943 from projectblacklight/fix_paginator
Facet paginator wraps a page of facets, it shouldn't paginate itself
2 parents bf3ecc3 + a39a8a9 commit df7728e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/blacklight/solr/facet_paginator.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ def params_for_resort_url(sort_method, params)
101101

102102
private
103103
# setting limit to 0 implies no limit
104+
# @return an array of facets on the page
104105
def items_for_limit(values)
105-
limit != 0 ? values.slice(offset, limit) : values
106+
limit == 0 ? values : values.take(limit)
106107
end
107108
end
108109
end

spec/lib/blacklight/facet_paginator_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
end
2727

2828
context 'on the last page of two pages' do
29-
subject { Blacklight::Solr::FacetPaginator.new(seven_facet_values, offset: 6, limit: limit) }
29+
subject { Blacklight::Solr::FacetPaginator.new([f7], offset: 6, limit: limit) }
3030
it { should_not be_first_page }
3131
it { should be_last_page }
3232
its(:current_page) { should eq 2 }
@@ -46,12 +46,12 @@
4646
describe "params_for_resort_url" do
4747
let(:sort_key) { Blacklight::Solr::FacetPaginator.request_keys[:sort] }
4848
let(:page_key) { Blacklight::Solr::FacetPaginator.request_keys[:page] }
49-
let(:paginator) { Blacklight::Solr::FacetPaginator.new(seven_facet_values, offset: 100, limit: limit, sort: 'index') }
49+
subject { Blacklight::Solr::FacetPaginator.new([], offset: 100, limit: limit, sort: 'index') }
5050

5151
it 'should know a manually set sort, and produce proper sort url' do
52-
expect(paginator.sort).to eq 'index'
52+
expect(subject.sort).to eq 'index'
5353

54-
click_params = paginator.params_for_resort_url('count', {})
54+
click_params = subject.params_for_resort_url('count', {})
5555

5656
expect(click_params[ sort_key ]).to eq 'count'
5757
expect(click_params[ page_key ]).to be_nil
@@ -64,5 +64,5 @@
6464
expect(subject.items).to eq seven_facet_values
6565
end
6666
end
67-
67+
6868
end

0 commit comments

Comments
 (0)