summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-01-03 11:19:53 -0800
committerdanielsdeleo <dan@opscode.com>2013-01-03 16:28:26 -0800
commit2eeed3b2c19383e7892ddbf01a903129c32292c9 (patch)
treefcbf7f914adada736798d35f72fa0253b1575900
parentdaab98592920fd8aeb32fb9cd539b6019614c698 (diff)
downloadchef-2eeed3b2c19383e7892ddbf01a903129c32292c9.tar.gz
[CHEF-3557] fix reporting for directory-like resources
-rw-r--r--lib/chef/provider/directory.rb1
-rw-r--r--spec/functional/resource/directory_spec.rb2
-rw-r--r--spec/functional/resource/remote_directory_spec.rb1
-rw-r--r--spec/support/shared/functional/securable_resource_with_reporting.rb10
-rw-r--r--spec/unit/provider/cookbook_file_spec.rb8
-rw-r--r--spec/unit/provider/directory_spec.rb3
6 files changed, 13 insertions, 12 deletions
diff --git a/lib/chef/provider/directory.rb b/lib/chef/provider/directory.rb
index 73940381da..8fdc070c77 100644
--- a/lib/chef/provider/directory.rb
+++ b/lib/chef/provider/directory.rb
@@ -110,6 +110,7 @@ class Chef
end
end
set_all_access_controls
+ update_new_file_state
end
def action_delete
diff --git a/spec/functional/resource/directory_spec.rb b/spec/functional/resource/directory_spec.rb
index 0576baab37..9ae0503336 100644
--- a/spec/functional/resource/directory_spec.rb
+++ b/spec/functional/resource/directory_spec.rb
@@ -23,6 +23,8 @@ describe Chef::Resource::Directory do
let(:directory_base) { "directory_spec" }
+ let(:default_mode) { "755" }
+
def create_resource
events = Chef::EventDispatch::Dispatcher.new
node = Chef::Node.new
diff --git a/spec/functional/resource/remote_directory_spec.rb b/spec/functional/resource/remote_directory_spec.rb
index 12d6b2d03e..b4e26a59b2 100644
--- a/spec/functional/resource/remote_directory_spec.rb
+++ b/spec/functional/resource/remote_directory_spec.rb
@@ -22,6 +22,7 @@ describe Chef::Resource::RemoteDirectory do
include_context Chef::Resource::Directory
let(:directory_base) { "directory_spec" }
+ let(:default_mode) { "755" }
def create_resource
cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks"))
diff --git a/spec/support/shared/functional/securable_resource_with_reporting.rb b/spec/support/shared/functional/securable_resource_with_reporting.rb
index f3d4fa6ec5..a7b705ee5c 100644
--- a/spec/support/shared/functional/securable_resource_with_reporting.rb
+++ b/spec/support/shared/functional/securable_resource_with_reporting.rb
@@ -98,8 +98,10 @@ shared_examples_for "a securable resource with reporting" do
end
context "and mode is specified as a String" do
- let(:set_mode) { "0440" }
- let(:expected_mode) { "440" }
+ # Need full permission for owner here or else remote directory gets
+ # into trouble trying to manage nested directories
+ let(:set_mode) { "0740" }
+ let(:expected_mode) { "740" }
before do
resource.mode(set_mode)
@@ -112,9 +114,9 @@ shared_examples_for "a securable resource with reporting" do
end
context "and mode is specified as an Integer" do
- let(:set_mode) { 00440 }
+ let(:set_mode) { 00740 }
- let(:expected_mode) { "440" }
+ let(:expected_mode) { "740" }
before do
resource.mode(set_mode)
resource.run_action(:create)
diff --git a/spec/unit/provider/cookbook_file_spec.rb b/spec/unit/provider/cookbook_file_spec.rb
index c70a7d852c..6761eba692 100644
--- a/spec/unit/provider/cookbook_file_spec.rb
+++ b/spec/unit/provider/cookbook_file_spec.rb
@@ -85,7 +85,7 @@ EXPECTED
@provider.current_resource = @current_resource
end
- after { ::File.exist?(@install_to) && FileUtils.rm(@install_to) }
+ after { ::File.exist?(File.dirname(@install_to)) && FileUtils.rm_rf(@install_to) }
it "loads the current file state" do
@provider.load_current_resource
@@ -97,12 +97,6 @@ EXPECTED
@provider.file_cache_location.should == expected
end
- it "stages the cookbook to a temporary file" do
- @new_resource.path(@install_to)
- @provider.should_receive(:deploy_tempfile)
- @provider.run_action(:create)
- end
-
it "installs the file from the cookbook cache" do
@new_resource.path(@install_to)
@provider.should_receive(:backup_new_resource)
diff --git a/spec/unit/provider/directory_spec.rb b/spec/unit/provider/directory_spec.rb
index 598bb46f0d..26e1d9d562 100644
--- a/spec/unit/provider/directory_spec.rb
+++ b/spec/unit/provider/directory_spec.rb
@@ -123,7 +123,8 @@ describe Chef::Provider::Directory do
it "should not create the directory if it already exists" do
stub_file_cstats
@new_resource.path "/tmp/foo"
- File.should_receive(:exist?).exactly(2).and_return(true)
+ File.should_receive(:directory?).twice.and_return(true)
+ File.should_receive(:exist?).exactly(3).and_return(true)
Dir.should_not_receive(:mkdir).with(@new_resource.path)
@directory.should_receive(:set_all_access_controls)
@directory.run_action(:create)