mattbeedle / capsule_crm

Ruby CapsuleCRM API consumer
MIT License
26 stars 16 forks source link

Boolean custom fields not serialized correctly #99

Closed madleech closed 8 years ago

madleech commented 8 years ago

Test case:

f = CapsuleCRM::CustomField.new(label: 'Test', boolean: false)                                                                                                                                         
# => #<CapsuleCRM::CustomField:53022300 id: , label: Test, date: , tag: , boolean: false, text: , party_id: , opportunity_id: , case_id: >

f.to_capsule_json                                                                                                                                                                                      
# => {"customField"=>{"label"=>"Test"}}

Capsule needs a value for a custom field, otherwise the PUT operation is ignored.

Bug is at: serializer.cleaned_attributes where it checks value.blank?, however becuase false.blank? returns true the boolean key is excluded from the generated JSON.

madleech commented 8 years ago

Further investigating seems to suggest that while the output of to_capsule_json looks wrong for a boolean false, it works correctly with Capsule itself.