Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix for being over zealous with the fields to null, now can update fi…

…elds to false
  • Loading branch information...
commit cbcec8cc0dc2579dd1b3d63fe9b54b6309220c1d 1 parent 9a177cb
@adelcambre adelcambre authored
Showing with 11 additions and 1 deletion.
  1. +1 −1  lib/dm-salesforce/connection.rb
  2. +10 −0 spec/models/contact_spec.rb
View
2  lib/dm-salesforce/connection.rb
@@ -69,7 +69,7 @@ def make_object(klass_name, values)
obj = klass.new
values.each do |property,value|
field = field_name_for(klass_name, property)
- if value.blank?
+ if value.nil? or value == ""
obj.fieldsToNull.push(field)
else
obj.send("#{field}=", value)
View
10 spec/models/contact_spec.rb
@@ -9,6 +9,7 @@ def self.default_repository_name
property :last_name, String
property :email, String
property :irc_nick, String
+ property :has_opted_out_of_email, Boolean
repository(:salesforce) do
property :id, String, :serial => true
@@ -93,5 +94,14 @@ def self.default_repository_name
c.errors.on(:last_name).should == ["Required fields are missing: [LastName]"]
end
end
+
+ describe "when updating a field to false" do
+ it "should update" do
+ c = Contact.create(:first_name => 'Per', :last_name => 'Son', :email => "person@company.com", :has_opted_out_of_email => true)
+ c.update_attributes(:has_opted_out_of_email => false)
+ c.should be_valid
+ c.has_opted_out_of_email.should_not be_true
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.