test/response_test.rb in rsolr-ext-0.10.1 vs test/response_test.rb in rsolr-ext-0.11.0
- old
+ new
@@ -16,10 +16,12 @@
r = RSolr::Ext::Response::Base.new(raw_response)
assert r.respond_to?(:response)
assert r.ok?
assert_equal 11, r.docs.size
assert_equal 'EXPLICIT', r.params[:echoParams]
+ assert_equal 1, r.docs.previous_page
+ assert_equal 2, r.docs.next_page
#
assert r.kind_of?(RSolr::Ext::Response::Docs)
assert r.kind_of?(RSolr::Ext::Response::Facets)
end
@@ -45,10 +47,11 @@
assert field_names.include?('cat')
assert field_names.include?('manu')
first_facet = r.facets.first
assert_equal 'cat', first_facet.name
+
assert_equal 10, first_facet.items.size
expected = first_facet.items.collect do |item|
item.value + ' - ' + item.hits.to_s
end.join(', ')
@@ -68,7 +71,36 @@
raw_response = eval(mock_query_response)
r = RSolr::Ext::Response::Base.new(raw_response)
facet = r.facet_by_field_name('cat')
assert_equal 'cat', facet.name
end
+
+=begin
+
+ # pagination for facets has been commented out in the response/facets module.
+ # ...need to think more about how this can be handled
+
+ test 'response::standard facets.paginate' do
+ raw_response = eval(mock_query_response)
+ raw_response['responseHeader']['params']['facet.offset'] = 1
+ raw_response['responseHeader']['params']['facet.limit'] = 2
+
+ r = RSolr::Ext::Response::Standard.new(raw_response)
+
+ assert_equal 2, r.facets.current_page
+
+ # always 1 less than facet.limit
+ assert_equal 1, r.facets.per_page
+
+ assert_equal 3, r.facets.next_page
+
+ assert_equal 1, r.facets.previous_page
+
+ # can't know how many pages there are with facets.... so we set it to -1
+ assert_equal -1, r.facets.total_pages
+
+ assert r.facets.has_next?
+ assert r.facets.has_previous?
+ end
+=end
end
\ No newline at end of file