Skip to content

Commit 2f5db2c

Browse files
authored
Merge pull request #284 from senid231/278-update-faraday-to-fix-empty-array-param-issue
#278 updating faraday to fix issue when param value is an empty array
2 parents fe506b5 + 12acf88 commit 2f5db2c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

json_api_client.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
1212
s.summary = 'Build client libraries compliant with specification defined by jsonapi.org'
1313

1414
s.add_dependency "activesupport", '>= 3.2.0'
15-
s.add_dependency "faraday", '~> 0.9'
15+
s.add_dependency "faraday", ['~> 0.15', '>= 0.15.2']
1616
s.add_dependency "faraday_middleware", '~> 0.9'
1717
s.add_dependency "addressable", '~> 2.2'
1818
s.add_dependency "activemodel", '>= 3.2.0'

test/unit/query_builder_test.rb

+25
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,29 @@ def test_can_select_nested_fields_using_comma_separated_strings
195195
Article.select({comments: 'author,text'}, :tags).to_a
196196
end
197197

198+
def test_can_specify_array_filter_value
199+
stub_request(:get, "http://example.com/articles?filter%5Bauthor.id%5D%5B0%5D=foo&filter%5Bauthor.id%5D%5B1%5D=bar")
200+
.to_return(headers: {content_type: "application/vnd.api+json"}, body: {
201+
data: []
202+
}.to_json)
203+
Article.where(:'author.id' => ['foo', 'bar']).to_a
204+
end
205+
206+
def test_can_specify_empty_array_filter_value
207+
stub_request(:get, "http://example.com/articles?filter%5Bauthor.id%5D%5B0%5D")
208+
.to_return(headers: {content_type: "application/vnd.api+json"}, body: {
209+
data: []
210+
}.to_json)
211+
Article.where(:'author.id' => []).to_a
212+
end
213+
214+
def test_can_specify_empty_string_filter_value
215+
stub_request(:get, "http://example.com/articles")
216+
.with(query: {filter: {:'author.id' => ''}})
217+
.to_return(headers: {content_type: "application/vnd.api+json"}, body: {
218+
data: []
219+
}.to_json)
220+
Article.where(:'author.id' => '').to_a
221+
end
222+
198223
end

0 commit comments

Comments
 (0)