Skip to content

Commit

Permalink
Merge pull request #83 from pablomouzo/update-attributes-symbols
Browse files Browse the repository at this point in the history
Fix update_attributes when hash uses symbols as keys
  • Loading branch information
ejholmes committed Jun 23, 2012
2 parents 113b5a5 + fbc8670 commit ba8c724
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/databasedotcom/client.rb
Expand Up @@ -494,7 +494,7 @@ def coerced_json(attrs, clazz)
if attrs.is_a?(Hash)
coerced_attrs = {}
attrs.keys.each do |key|
case clazz.field_type(key)
case clazz.field_type(key.to_s)
when "multipicklist"
coerced_attrs[key] = (attrs[key] || []).join(';')
when "datetime"
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/client_spec.rb
Expand Up @@ -875,6 +875,12 @@ class Something;
WebMock.should have_requested(:patch, "https://na1.salesforce.com/services/data/v23.0/sobjects/Whizbang/rid")
end

it "persists the updated changes with names as symbols" do
stub_request(:patch, "https://na1.salesforce.com/services/data/v23.0/sobjects/Whizbang/rid").to_return(:body => nil, :status => 204)
@client.update("Whizbang", "rid", {:Name => "update"})
WebMock.should have_requested(:patch, "https://na1.salesforce.com/services/data/v23.0/sobjects/Whizbang/rid")
end

it "applies type coercions before serializing" do
stub_request(:patch, "https://na1.salesforce.com/services/data/v23.0/sobjects/Whizbang/rid").to_return(:body => nil, :status => 204)
@client.update("Whizbang", "rid", "Date_Field" => Date.civil(2011, 1, 1), "DateTime_Field" => DateTime.civil(2011, 2, 1, 12), "Picklist_Multiselect_Field" => %w(a b))
Expand Down

0 comments on commit ba8c724

Please sign in to comment.