Permalink
Browse files

fixed problem with current page when no records were found

  • Loading branch information...
dcrec1 committed May 24, 2010
1 parent dc5853a commit c7d447eee024b15f1b15127c7c25edbd975c254f
Showing with 9 additions and 5 deletions.
  1. +5 −5 lib/acts_as_solr/parser_methods.rb
  2. +4 −0 test/functional/acts_as_solr_test.rb
@@ -121,6 +121,11 @@ def parse_results(solr_data, options = {})
}
results.update(:spellcheck => solr_data.data['spellcheck']) unless solr_data.nil?
results.update(:facets => {'facet_fields' => []}) if options[:facets]
+ unless solr_data.header['params'].nil?
+ header = solr_data.header
+ results.update :rows => header['params']['rows']
+ results.update :start => header['params']['start']
+ end
return SearchResults.new(results) if (solr_data.nil? || solr_data.total_hits == 0)
configuration.update(options) if options.is_a?(Hash)
@@ -141,11 +146,6 @@ def parse_results(solr_data, options = {})
results.update(:facets => solr_data.data['facet_counts']) if options[:facets]
results.update({:docs => result, :total => solr_data.total_hits, :max_score => solr_data.max_score, :query_time => solr_data.data['responseHeader']['QTime']})
results.update({:highlights=>highlighted})
- unless solr_data.header['params'].nil?
- header = solr_data.header
- results.update :rows => header['params']['rows']
- results.update :start => header['params']['start']
- end
SearchResults.new(results)
end
@@ -486,4 +486,8 @@ def test_current_page_is_returned
def test_current_page_1_is_returned
assert_equal 1, Posting.search("test").current_page
end
+
+ def test_current_page_1_is_returned_when_no_records_found
+ assert_equal 1, Posting.search("nothing").current_page
+ end
end

0 comments on commit c7d447e

Please sign in to comment.