summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Goodman <allen@goodman.io>2013-12-06 10:25:44 -0500
committerAllen Goodman <allen@goodman.io>2013-12-06 10:25:44 -0500
commitee62d011a5b72473c66f95d68a2b4c82f32db5c9 (patch)
tree0686d043fb3632b06161dcd87b60f6909871cf4f
parenta03cc741bccbbd31cea1f9834d5337ef69e8db0c (diff)
downloadchef-ee62d011a5b72473c66f95d68a2b4c82f32db5c9.tar.gz
fixes CHEF-4639
-rw-r--r--lib/chef/provider/file.rb10
-rw-r--r--spec/support/shared/functional/file_resource.rb25
2 files changed, 22 insertions, 13 deletions
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb
index cb6383fc46..b06e07e23e 100644
--- a/lib/chef/provider/file.rb
+++ b/lib/chef/provider/file.rb
@@ -345,6 +345,10 @@ class Chef
if ::File.file?(@new_resource.path) && contents_changed?
if @new_resource.sensitive
@new_resource.diff('suppressed sensitive resource')
+
+ converge_by(['suppressed sensitive resource']) do
+ update_file_contents
+ end
else
diff.diff(@current_resource.path, tempfile.path)
@@ -353,10 +357,10 @@ class Chef
description = [ "update content in file #{@new_resource.path} from #{short_cksum(@current_resource.checksum)} to #{short_cksum(checksum(tempfile.path))}" ]
description << diff.for_output
- end
- converge_by(description) do
- update_file_contents
+ converge_by(description) do
+ update_file_contents
+ end
end
end
diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index e9e76c95db..b7536ce1d6 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -16,6 +16,8 @@
# limitations under the License.
#
+require 'pry'
+
shared_context "deploying with move" do
before do
Chef::Config[:file_backup_path] = CHEF_SPEC_BACKUP_PATH
@@ -133,24 +135,27 @@ shared_examples_for "a file with the wrong content" do
end
- context '`.diff`’s enabled' do
+ context "`.diff`'s enabled" do
describe '.sensitive' do
- context '`.sensitive`’s insensitive by default' do
+ context "`.sensitive`'s insensitive by default" do
it { expect(resource.sensitive).to(be_false) }
end
- context '`.sensitive`’s sensitive' do
- before do
- resource.sensitive(true)
-
- resource.run_action(:create)
- end
+ context "`.sensitive`'s sensitive" do
+ before { resource.sensitive(true) }
it { expect(resource.sensitive).to(be_true) }
- it { expect(resource.diff).to(include('suppressed sensitive resource')) }
+ context '`.sensitive` suppresses a sensitive resource' do
+ subject(:provider) { resource.provider_for_action(:create) }
+
+ before { provider.run_action }
- # it { expect(resource.provider.converge_actions).to include('suppressed sensitive resource') }
+ it { expect(resource.diff).to(include('suppressed sensitive resource')) }
+
+ it { expect(provider.instance_variable_get("@converge_actions")
+ .actions[0][0]).to(eq(['suppressed sensitive resource'])) }
+ end
end
end
end