diff --git a/lib/fog/core/attributes.rb b/lib/fog/core/attributes.rb index cab8d6f52..0a4b7ca4c 100644 --- a/lib/fog/core/attributes.rb +++ b/lib/fog/core/attributes.rb @@ -25,9 +25,9 @@ module Fog class_eval <<-EOS, __FILE__, __LINE__ def #{name}=(new_#{name}) attributes[:#{name}] = case new_#{name} - when 'true' + when true,'true' true - when 'false' + when false,'false' false end end diff --git a/tests/core/attribute_tests.rb b/tests/core/attribute_tests.rb index 2b26c72a9..63fd5e57a 100644 --- a/tests/core/attribute_tests.rb +++ b/tests/core/attribute_tests.rb @@ -1,6 +1,7 @@ class FogAttributeTestModel < Fog::Model attribute :key, :aliases => 'keys', :squash => "id" attribute :time, :type => :time + attribute :bool, :type => :boolean end Shindo.tests('Fog::Attributes', 'core') do @@ -51,4 +52,32 @@ Shindo.tests('Fog::Attributes', 'core') do end + tests(':type => :boolean') do + tests(':bool => "true"').returns(true) do + @model.merge_attributes(:bool => 'true') + @model.bool + end + + tests(':bool => true').returns(true) do + @model.merge_attributes(:bool => true) + @model.bool + end + + tests(':bool => "false"').returns(false) do + @model.merge_attributes(:bool => 'false') + @model.bool + end + + tests(':bool => false').returns(false) do + @model.merge_attributes(:bool => false) + @model.bool + end + + tests(':bool => "foo"').returns(nil) do + @model.merge_attributes(:bool => "foo") + @model.bool + end + + end + end