diff options
author | Paul Berry <paul@puppetlabs.com> | 2011-01-25 14:34:28 -0800 |
---|---|---|
committer | Paul Berry <paul@puppetlabs.com> | 2011-01-25 15:12:47 -0800 |
commit | 67e1bba154accd900b9690d96cec8b050f8082e7 (patch) | |
tree | 54050ace3795a6671fa757464f2acc7809f466c3 /spec/unit/type/file_spec.rb | |
parent | 0f9d23617e4115166d6b9e004332dcdf5eccc924 (diff) | |
download | puppet-67e1bba154accd900b9690d96cec8b050f8082e7.tar.gz puppet-67e1bba154accd900b9690d96cec8b050f8082e7.tar.xz puppet-67e1bba154accd900b9690d96cec8b050f8082e7.zip |
(#5931) Prevent errors when calling insync? on audited properties
Created a method safe_insync? which first checks whether the property
has a "should" value of nil, and if so returns true. Most insync?
methods were already doing this, but a few were not, leading to bugs
if a property was being audited but not set.
Types should continue to override the insync? method, but callers of
insync? should call safe_insync? instead.
Paired-with: Jesse Wolfe <jesse@puppetlabs.com>
Diffstat (limited to 'spec/unit/type/file_spec.rb')
-rwxr-xr-x | spec/unit/type/file_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb index 22921d85a..51c27c0e6 100755 --- a/spec/unit/type/file_spec.rb +++ b/spec/unit/type/file_spec.rb @@ -1065,4 +1065,18 @@ describe Puppet::Type.type(:file) do end end + describe "when auditing" do + it "should not fail if creating a new file if group is not set" do + File.exists?(@path).should == false + file = Puppet::Type::File.new(:name => @path, :audit => "all", :content => "content") + catalog = Puppet::Resource::Catalog.new + catalog.add_resource(file) + + Puppet::Util::Storage.stubs(:store) # to prevent the catalog from trying to write state.yaml + transaction = catalog.apply + + transaction.report.resource_statuses["File[#{@path}]"].failed.should == false + File.exists?(@path).should == true + end + end end |