Skip to content

Commit

Permalink
When filtering search results, pagination isn't really going to work …
Browse files Browse the repository at this point in the history
…anyway since we don't know the true total.

This reverts commit 7f66781.
  • Loading branch information
nz committed Nov 2, 2010
1 parent 7f66781 commit 024c233
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
2 changes: 1 addition & 1 deletion sunspot/lib/sunspot/search/abstract_search.rb
Expand Up @@ -280,7 +280,7 @@ def verified_hits

def maybe_will_paginate(collection)
if defined?(WillPaginate::Collection)
WillPaginate::Collection.create(@query.page, @query.per_page, collection.size) do |pager|
WillPaginate::Collection.create(@query.page, @query.per_page, total) do |pager|
pager.replace(collection)
end
else
Expand Down
19 changes: 3 additions & 16 deletions sunspot/spec/api/search/results_spec.rb
Expand Up @@ -33,23 +33,10 @@
if ENV['USE_WILL_PAGINATE']

it 'returns search total as attribute of results' do
posts = (1..4).map { Post.new }
stub_results(*posts)
search = session.search(Post) do
paginate(:page => 1)
end
search.hits.size.should == 4
search.results.total_entries.should == 4
end

it "returns correct total for filtered results" do
posts = (1..4).map { EvenPost.new }
stub_results(*posts)
search = session.search(EvenPost) do
stub_results(Post.new, 4)
session.search(Post) do
paginate(:page => 1)
end
search.hits.size.should == 4
search.results.total_entries.should == 2
end.results.total_entries.should == 4
end

else
Expand Down
11 changes: 0 additions & 11 deletions sunspot/spec/mocks/even_post.rb

This file was deleted.

0 comments on commit 024c233

Please sign in to comment.