Skip to content

Commit 3267ca8

Browse files
committed
Merge pull request #109 from ryanhertz/RUBYAPI-37-attribute-updating
RUBYAPI-37: fixed update_attributes
2 parents 5364f63 + 51a79eb commit 3267ca8

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/spark_api/models/concerns/savable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def create!(arguments = {})
2828
true
2929
end
3030

31-
def update_attributes(attrs = {})
32-
attrs.each{|k,v| public_send(:"#{k}=", v)}
31+
def update_attributes(attrs = {}, options = {})
32+
load(attrs, options)
3333
save!
3434
end
3535

spec/unit/spark_api/models/concerns/savable_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,14 @@ class MyPluralizedModels < Base
7474
s.should have_been_requested
7575
end
7676

77+
describe "update_attributes" do
78+
it "loads the attributes" do
79+
model = MyExampleModel.new
80+
new_attributes = {Name: "My Name"}
81+
expect(model).to receive(:load).with(new_attributes, {})
82+
expect(model).to receive(:save!)
83+
model.update_attributes(new_attributes)
84+
end
85+
end
86+
7787
end

0 commit comments

Comments
 (0)