Commit 5c3b34b9408ef4a5134e544da4e113d4e5fb9835

Authored by Yuki Nishijima
1 parent 9d067a77

Add Results#entry_name method for kaminari compatibility

From kaminari 0.16.0, `page_entries_info` requires paginatable objects
to have `#entry_name` method. SearchKick::Results class should also have
it so it'll play nice together with kaminari.
lib/searchkick/results.rb
@@ -88,6 +88,10 @@ module Searchkick @@ -88,6 +88,10 @@ module Searchkick
88 klass.model_name 88 klass.model_name
89 end 89 end
90 90
  91 + def entry_name
  92 + model_name.human.downcase
  93 + end
  94 +
91 def total_count 95 def total_count
92 response["hits"]["total"] 96 response["hits"]["total"]
93 end 97 end
test/sql_test.rb
@@ -22,6 +22,7 @@ class TestSql < Minitest::Test @@ -22,6 +22,7 @@ class TestSql < Minitest::Test
22 store_names ["Product A", "Product B", "Product C", "Product D", "Product E", "Product F"] 22 store_names ["Product A", "Product B", "Product C", "Product D", "Product E", "Product F"]
23 products = Product.search("product", order: {name: :asc}, page: 2, per_page: 2, padding: 1) 23 products = Product.search("product", order: {name: :asc}, page: 2, per_page: 2, padding: 1)
24 assert_equal ["Product D", "Product E"], products.map(&:name) 24 assert_equal ["Product D", "Product E"], products.map(&:name)
  25 + assert_equal "product", products.entry_name
25 assert_equal 2, products.current_page 26 assert_equal 2, products.current_page
26 assert_equal 1, products.padding 27 assert_equal 1, products.padding
27 assert_equal 2, products.per_page 28 assert_equal 2, products.per_page
test/test_helper.rb
@@ -11,6 +11,8 @@ Minitest::Test = Minitest::Unit::TestCase unless defined?(Minitest::Test) @@ -11,6 +11,8 @@ Minitest::Test = Minitest::Unit::TestCase unless defined?(Minitest::Test)
11 File.delete("elasticsearch.log") if File.exists?("elasticsearch.log") 11 File.delete("elasticsearch.log") if File.exists?("elasticsearch.log")
12 Searchkick.client.transport.logger = Logger.new("elasticsearch.log") 12 Searchkick.client.transport.logger = Logger.new("elasticsearch.log")
13 13
  14 +I18n.config.enforce_available_locales = true
  15 +
14 if defined?(Mongoid) 16 if defined?(Mongoid)
15 17
16 def mongoid2? 18 def mongoid2?