Skip to content

Commit

Permalink
Merge pull request #17 from ifad/feature/support-pagy
Browse files Browse the repository at this point in the history
Add Pagy support
  • Loading branch information
tagliala authored Feb 1, 2022
2 parents 61b6f01 + d5ee1aa commit f047128
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/hawk/model/finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def all(params = {})
end

def count(params = {})
params = {} unless params.is_a?(Hash)
path = path_for(count_path, params)
method = connection.url_length(path,:get,params) > 2000 ? :post : :get
repr = connection.send(method, path, params)
Expand Down
10 changes: 9 additions & 1 deletion spec/collections_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,20 @@ class Mosquito < Hawk::Model::Base
end

describe '.count' do
specify do
before do
stub_request(:GET, "http://zombo.com/mosquitos/count").
with(:headers => {'User-Agent'=>'Foobar'}).
to_return(:status => 200, :body => {count: 123}.to_json, :headers => {})
end

specify do
expect(Mosquito.count).to eq(123)
end

context 'when parameter is not a hash' do
specify do
expect { Mosquito.count(:all) }.not_to raise_error
end
end
end
end

0 comments on commit f047128

Please sign in to comment.