From 72778886a10c04647edbe1ddc4c180bcde9e991e Mon Sep 17 00:00:00 2001 From: Brian Hartsock Date: Wed, 20 Jul 2011 18:18:05 -0400 Subject: [PATCH] Fixed #444 - Unable to squash kvp with false values --- lib/fog/core/attributes.rb | 6 ++++-- tests/core/attribute_tests.rb | 11 ++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/fog/core/attributes.rb b/lib/fog/core/attributes.rb index a7dcd0360..cab8d6f52 100644 --- a/lib/fog/core/attributes.rb +++ b/lib/fog/core/attributes.rb @@ -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 diff --git a/tests/core/attribute_tests.rb b/tests/core/attribute_tests.rb index c3122ec0a..2b26c72a9 100644 --- a/tests/core/attribute_tests.rb +++ b/tests/core/attribute_tests.rb @@ -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 \ No newline at end of file +end