Skip to content

Commit

Permalink
Facet paginator wraps a page of facets, it shouldn't paginate itself
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jul 8, 2014
1 parent b10011a commit a39a8a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/blacklight/solr/facet_paginator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ def params_for_resort_url(sort_method, params)

private
# setting limit to 0 implies no limit
# @return an array of facets on the page
def items_for_limit(values)
limit != 0 ? values.slice(offset, limit) : values
limit == 0 ? values : values.take(limit)
end
end
end
10 changes: 5 additions & 5 deletions spec/lib/blacklight/facet_paginator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
end

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

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

click_params = paginator.params_for_resort_url('count', {})
click_params = subject.params_for_resort_url('count', {})

expect(click_params[ sort_key ]).to eq 'count'
expect(click_params[ page_key ]).to be_nil
Expand All @@ -64,5 +64,5 @@
expect(subject.items).to eq seven_facet_values
end
end

end

0 comments on commit a39a8a9

Please sign in to comment.