Skip to content

kaminari divided by 0 error #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion elasticsearch-model/lib/elasticsearch/model/searching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initialize(klass, query_or_payload, options={})
case
# search query: ...
when query_or_payload.respond_to?(:to_hash)
body = query_or_payload.to_hash
body = query_or_payload.to_hash.deep_symbolize_keys

# search '{ "query" : ... }'
when query_or_payload.is_a?(String) && query_or_payload =~ /^\s*{/
Expand Down
13 changes: 13 additions & 0 deletions elasticsearch-model/test/unit/response_pagination_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ def self.document_type; 'bar'; end
assert_equal 50, @response.limit_value
assert_equal 10, @response.offset_value
end

should "return the value from body with object responding to `to_hash`" do
query = Hashie::Mash.new({
query: { match_all: {} },
size: 50,
from: 10
})
search = Elasticsearch::Model::Searching::SearchRequest.new ModelClass, query
@response = Elasticsearch::Model::Response::Response.new ModelClass, search, RESPONSE

assert_equal 50, @response.limit_value
assert_equal 10, @response.offset_value
end
end

context "limit setter" do
Expand Down