Fixed #444 - Unable to squash kvp with false values

This commit is contained in:
Brian Hartsock 2011-07-20 18:18:05 -04:00
parent 1f717648c2
commit 72778886a1
2 changed files with 14 additions and 3 deletions

View File

@ -71,8 +71,10 @@ module Fog
class_eval <<-EOS, __FILE__, __LINE__
def #{name}=(new_data)
if new_data.is_a?(Hash)
if new_data[:#{squash}] || new_data["#{squash}"]
attributes[:#{name}] = new_data[:#{squash}] || new_data["#{squash}"]
if new_data.has_key?(:#{squash})
attributes[:#{name}] = new_data[:#{squash}]
elsif new_data.has_key?("#{squash}")
attributes[:#{name}] = new_data["#{squash}"]
else
attributes[:#{name}] = [ new_data ]
end

View File

@ -19,6 +19,15 @@ Shindo.tests('Fog::Attributes', 'core') do
@model.key
end
tests('"keys" => {"id" => false}').returns(false) do
@model.merge_attributes("keys" => {'id' => false })
@model.key
end
tests('"keys" => {:id => false}').returns(false) do
@model.merge_attributes("keys" => {:id => false })
@model.key
end
end
tests(':type => :time') do
@ -42,4 +51,4 @@ Shindo.tests('Fog::Attributes', 'core') do
end
end
end