Permalink
Browse files

Merge pull request #83 from pablomouzo/update-attributes-symbols

Fix update_attributes when hash uses symbols as keys
  • Loading branch information...
2 parents 113b5a5 + fbc8670 commit ba8c72456c7dba399002e553ca75214990a01360 @ejholmes ejholmes committed Jun 23, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/databasedotcom/client.rb
  2. +6 −0 spec/lib/client_spec.rb
@@ -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"
View
@@ -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))

0 comments on commit ba8c724

Please sign in to comment.