diff --git a/lib/fog/rackspace/models/storage/metadata.rb b/lib/fog/rackspace/models/storage/metadata.rb index 62bedb572..1668e2405 100644 --- a/lib/fog/rackspace/models/storage/metadata.rb +++ b/lib/fog/rackspace/models/storage/metadata.rb @@ -18,11 +18,18 @@ module Fog def initialize(hash={}) @data = hash || {} + @deleted_hash = {} + end + + def delete(key) + data.delete(key) + @deleted_hash[key] = nil end def to_headers - headers = {} - @data.each_pair do |k,v| + headers = {} + h = data.merge(@deleted_hash) + h.each_pair do |k,v| key = to_header_key(k,v) headers[key] = v || DUMMY_VALUE end @@ -41,11 +48,11 @@ module Fog end def respond_to?(method_sym, include_private = false) - super(method_sym, include_private) || @data.method_missing(method_missing, include_private) + super(method_sym, include_private) || data.method_missing(method_missing, include_private) end def method_missing(method, *args, &block) - @data.send(method, *args, &block) + data.send(method, *args, &block) end private diff --git a/tests/rackspace/models/storage/directory_tests.rb b/tests/rackspace/models/storage/directory_tests.rb index fbfad3160..50ccbc585 100644 --- a/tests/rackspace/models/storage/directory_tests.rb +++ b/tests/rackspace/models/storage/directory_tests.rb @@ -32,11 +32,17 @@ Shindo.tests('Fog::Rackspace::Storage | directory', ['rackspace']) do @instance.save container_meta_attributes end - tests('delete metadata').returns({"X-Container-Meta-Draft"=>"true"}) do + tests('set metadata to nil').returns({"X-Container-Meta-Draft"=>"true"}) do @instance.metadata[:color] = nil @instance.save container_meta_attributes + end + tests('delete metadata').returns({}) do + @instance.metadata.delete(:draft) + @instance.save + container_meta_attributes end + end end