Skip to content

Commit dd73686

Browse files
authored
Merge pull request #121 from ryanhertz/MWEB-1179-defaultable-find-options
defaultable find options
2 parents e633be5 + 6217f22 commit dd73686

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v1.4.5
2+
- Fixed problem where options are dropped in Defaultable when `find` is called with 'default'
3+
14
v1.4.4
25
- Fixed symbol hash key bug in Defaultable
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.4
1+
1.4.5

lib/spark_api/models/defaultable.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def default(options = {})
2828

2929
def find(*arguments)
3030
if arguments.first == DEFAULT_ID
31-
default
31+
options = arguments.slice!(1) || {}
32+
default(options)
3233
else
3334
original_find(*arguments)
3435
end

spec/unit/spark_api/models/defaultable_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class TestClass < Base
4343
TestClass.find(TestClass::DEFAULT_ID)
4444
end
4545

46+
it "passes options to 'default'" do
47+
expect(TestClass).to receive(:default).with(foo: true)
48+
TestClass.find(TestClass::DEFAULT_ID, foo: true)
49+
end
50+
4651
it "calls Finders.find when given a normal id" do
4752
connection = double
4853
expect(connection).to receive(:get).with("/testclass/5", {foo: true}).and_return([{}])

0 commit comments

Comments
 (0)