Skip to content

Commit

Permalink
fix for being over zealous with the fields to null, now can update fi…
Browse files Browse the repository at this point in the history
…elds to false
  • Loading branch information
Andy Delcambre committed Dec 18, 2008
1 parent 9a177cb commit cbcec8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dm-salesforce/connection.rb
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions spec/models/contact_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit cbcec8c

Please sign in to comment.