From 8e713188410f66da32244aaf1fc44e22c8f721c2 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Fri, 22 Aug 2014 07:31:05 -0700 Subject: Get rspec data working again for creatorless data --- lib/chef_zero/chef_data/default_creator.rb | 2 +- lib/chef_zero/data_store/default_facade.rb | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/chef_zero') diff --git a/lib/chef_zero/chef_data/default_creator.rb b/lib/chef_zero/chef_data/default_creator.rb index 49bb542..eecc213 100644 --- a/lib/chef_zero/chef_data/default_creator.rb +++ b/lib/chef_zero/chef_data/default_creator.rb @@ -60,7 +60,7 @@ module ChefZero # Walk up the tree, setting the creator on anything that doesn't exist # (anything that is either deleted or was never created) while (deleted_index && path.size > deleted_index) || !@creators[path] - @creators[path] = [ creator ] + @creators[path] = creator ? [ creator ] : [] @deleted.delete(path) # Only do this once if create_parents is false break if !create_parents || path.size == 0 diff --git a/lib/chef_zero/data_store/default_facade.rb b/lib/chef_zero/data_store/default_facade.rb index c274102..c0e33b9 100644 --- a/lib/chef_zero/data_store/default_facade.rb +++ b/lib/chef_zero/data_store/default_facade.rb @@ -61,7 +61,7 @@ module ChefZero end end - options_hash = options.last || {} + options_hash = options.last.is_a?(Hash) ? options.last : {} default_creator.created(path + [ name ], options_hash[:requestor], options.include?(:recursive)) end @@ -82,7 +82,9 @@ module ChefZero begin real_store.set(path, data, *options) rescue DataNotFoundError - if default_creator.exists?(path) + if options.include?(:create_dir) || + options.include?(:create) && default_creator.exists?(path[0..-2]) || + default_creator.exists?(path) real_store.set(path, data, :create, :create_dir, *options) else raise @@ -90,7 +92,7 @@ module ChefZero end if options.include?(:create) - options_hash = options.last || {} + options_hash = options.last.is_a?(Hash) ? options.last : {} default_creator.created(path, options_hash[:requestor], options.include?(:create_dir)) end end -- cgit v1.2.1