diff options
| author | Luke Kanies <luke@madstop.com> | 2008-12-07 18:04:14 -0600 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2008-12-08 15:45:06 +1100 |
| commit | 18fe5c3ac2ad4c42afd30ba2effad28607fe746d (patch) | |
| tree | 7c4ba6b654aa6799d83a65861fc2ade479cf08b3 | |
| parent | b22303e31654b44c300c713426d7f16ef37f4210 (diff) | |
| download | puppet-18fe5c3ac2ad4c42afd30ba2effad28607fe746d.tar.gz puppet-18fe5c3ac2ad4c42afd30ba2effad28607fe746d.tar.xz puppet-18fe5c3ac2ad4c42afd30ba2effad28607fe746d.zip | |
Fixing #1750 again - All of the properties and now :ensure check replace?
Signed-off-by: Luke Kanies <luke@madstop.com>
| -rwxr-xr-x | lib/puppet/type/file/ensure.rb | 4 | ||||
| -rwxr-xr-x | spec/unit/type/file/ensure.rb | 21 |
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb index 3a1a824bd..175b821b3 100755 --- a/lib/puppet/type/file/ensure.rb +++ b/lib/puppet/type/file/ensure.rb @@ -137,6 +137,10 @@ module Puppet # We have to treat :present specially, because it works with any # type of file. def insync?(currentvalue) + unless currentvalue == :absent or resource.replace? + return true + end + if self.should == :present if currentvalue.nil? or currentvalue == :absent return false diff --git a/spec/unit/type/file/ensure.rb b/spec/unit/type/file/ensure.rb new file mode 100755 index 000000000..b336c7c7a --- /dev/null +++ b/spec/unit/type/file/ensure.rb @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby + +Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } + +property = Puppet::Type.type(:file).attrclass(:ensure) + +describe property do + before do + @resource = stub 'resource', :line => "foo", :file => "bar", :replace? => true + @resource.stubs(:[]).returns "foo" + @resource.stubs(:[]).with(:path).returns "/my/file" + @ensure = property.new :resource => @resource + end + + describe "when testing whether in sync" do + it "should always be in sync if replace is 'false' unless the file is missing" do + @resource.expects(:replace?).returns false + @ensure.insync?(:link).should be_true + end + end +end |
