Skip to content

#278 updating faraday to fix issue when param value is an empty array #284

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

Merged
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 json_api_client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.summary = 'Build client libraries compliant with specification defined by jsonapi.org'

s.add_dependency "activesupport", '>= 3.2.0'
s.add_dependency "faraday", '~> 0.9'
s.add_dependency "faraday", ['~> 0.15', '>= 0.15.2']
s.add_dependency "faraday_middleware", '~> 0.9'
s.add_dependency "addressable", '~> 2.2'
s.add_dependency "activemodel", '>= 3.2.0'
Expand Down
25 changes: 25 additions & 0 deletions test/unit/query_builder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,29 @@ def test_can_select_nested_fields_using_comma_separated_strings
Article.select({comments: 'author,text'}, :tags).to_a
end

def test_can_specify_array_filter_value
stub_request(:get, "http://example.com/articles?filter%5Bauthor.id%5D%5B0%5D=foo&filter%5Bauthor.id%5D%5B1%5D=bar")
.to_return(headers: {content_type: "application/vnd.api+json"}, body: {
data: []
}.to_json)
Article.where(:'author.id' => ['foo', 'bar']).to_a
end

def test_can_specify_empty_array_filter_value
stub_request(:get, "http://example.com/articles?filter%5Bauthor.id%5D%5B0%5D")
.to_return(headers: {content_type: "application/vnd.api+json"}, body: {
data: []
}.to_json)
Article.where(:'author.id' => []).to_a
end

def test_can_specify_empty_string_filter_value
stub_request(:get, "http://example.com/articles")
.with(query: {filter: {:'author.id' => ''}})
.to_return(headers: {content_type: "application/vnd.api+json"}, body: {
data: []
}.to_json)
Article.where(:'author.id' => '').to_a
end

end