Skip to content

Commit 526cdee

Browse files
committed
Raise argument error when args to find are nil, fixes instances where the collection endpoint is called instead where arguments are nil
1 parent d1b1086 commit 526cdee

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/json_api_client/query/builder.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def to_a
9494
alias all to_a
9595

9696
def find(args = {})
97+
raise ArgumentError, "Arguments cannot be nil" if args.nil?
9798
case args
9899
when Hash
99100
where(args)

test/unit/finding_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,10 @@ def test_find_all
7777
assert_equal ["2", "3"], articles.map(&:id)
7878
end
7979

80+
def test_find_nil
81+
assert_raises ArgumentError do
82+
Article.find(nil)
83+
end
84+
end
85+
8086
end

0 commit comments

Comments
 (0)