Permalink
Browse files

Fixed page_view_entries for Kaminari - fixes #934

  • Loading branch information...
ankane committed Jun 14, 2017
1 parent 85fc546 commit 0422c616c2198775ee93c59019b468054125a013
Showing with 55 additions and 2 deletions.
  1. +1 −0 CHANGELOG.md
  2. +4 −0 Gemfile
  3. +8 −2 lib/searchkick/results.rb
  4. +4 −0 test/gemfiles/mongoid6.gemfile
  5. +17 −0 test/pagination_test.rb
  6. +21 −0 test/support/kaminari.yml
View
@@ -1,6 +1,7 @@
## 2.3.1 [unreleased]
- Added support for passing fields to `suggest` option
- Fixed `page_view_entries` for Kaminari
## 2.3.0
View
@@ -10,3 +10,7 @@ gem "typhoeus"
gem "activejob"
gem "redis"
gem "connection_pool"
# kaminari
gem "actionpack"
gem "kaminari"
View
@@ -127,8 +127,14 @@ def model_name
klass.model_name
end
def entry_name
model_name.human.downcase
def entry_name(options = {})
if options.empty?
# backward compatibility
model_name.human.downcase
else
default = options[:count] == 1 ? model_name.human : model_name.human.pluralize
model_name.human(options.reverse_merge(default: default))
end
end
def total_count
@@ -6,3 +6,7 @@ gemspec path: "../../"
gem "mongoid", "~> 6.0.0"
gem "activejob"
gem "redis"
# kaminari
gem "actionpack"
gem "kaminari"
View
@@ -50,4 +50,21 @@ def test_pagination_nil_page
assert_equal 1, products.current_page
assert products.first_page?
end
def test_kaminari
skip unless defined?(Kaminari)
require "action_view"
I18n.load_path = Dir["test/support/kaminari.yml"]
I18n.backend.load_translations
view = ActionView::Base.new
store_names ["Product A"]
assert_equal "Displaying <b>1</b> product", view.page_entries_info(Product.search("product"))
store_names ["Product B"]
assert_equal "Displaying <b>all 2</b> products", view.page_entries_info(Product.search("product"))
end
end
View
@@ -0,0 +1,21 @@
en:
views:
pagination:
first: "&laquo; First"
last: "Last &raquo;"
previous: "&lsaquo; Prev"
next: "Next &rsaquo;"
truncate: "&hellip;"
helpers:
page_entries_info:
entry:
zero: "entries"
one: "entry"
other: "entries"
one_page:
display_entries:
zero: "No %{entry_name} found"
one: "Displaying <b>1</b> %{entry_name}"
other: "Displaying <b>all %{count}</b> %{entry_name}"
more_pages:
display_entries: "Displaying %{entry_name} <b>%{first}&nbsp;-&nbsp;%{last}</b> of <b>%{total}</b> in total"

0 comments on commit 0422c61

Please sign in to comment.