Skip to content

Commit c13d90e

Browse files
committed
allow to update deal without passing deal value
1 parent d582c93 commit c13d90e

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/basecrm/services/deals_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def extract_params!(deal, *args)
133133

134134
def sanitize(deal)
135135
deal_hash = deal.to_h.select { |k, _| OPTS_KEYS_TO_PERSIST.include?(k) }
136-
deal_hash[:value] = Coercion.to_string(deal_hash[:value])
136+
deal_hash[:value] = Coercion.to_string(deal_hash[:value]) if deal_hash[:value]
137137
deal_hash
138138
end
139139
end

spec/services/deals_service_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
@deal = create(:deal)
5353
expect(client.deals.update(@deal)).to be_instance_of BaseCRM::Deal
5454
end
55+
56+
it "allows to skip deal value in payload" do
57+
@deal = create(:deal, value: nil)
58+
expect(client.deals.update(@deal)).to be_instance_of BaseCRM::Deal
59+
end
5560
end
5661

5762
describe :destroy do

0 commit comments

Comments
 (0)