summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/property.rb4
-rw-r--r--lib/puppet/type.rb7
-rw-r--r--lib/puppet/type/file.rb3
-rwxr-xr-xlib/puppet/type/file/content.rb2
-rwxr-xr-xlib/puppet/type/file/ensure.rb4
-rwxr-xr-xspec/unit/type.rb5
-rwxr-xr-xtest/network/handler/master.rb2
-rwxr-xr-xtest/ral/type/user.rb2
8 files changed, 21 insertions, 8 deletions
diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb
index fd3492970..f8a17ac07 100644
--- a/lib/puppet/property.rb
+++ b/lib/puppet/property.rb
@@ -291,7 +291,7 @@ class Puppet::Property < Puppet::Parameter
# Set a name for looking up associated options like the event.
name = self.class.value_name(value)
- call = self.class.value_option(name, :call)
+ call = self.class.value_option(name, :call) || :none
if call == :instead
event, tmp = call_valuemethod(name, value)
@@ -310,7 +310,7 @@ class Puppet::Property < Puppet::Parameter
# was never used, and it makes things unecessarily complicated.
# If you want to specify a block and still call the setter, then
# do so in the block.
- devfail "Cannot use obsolete :call value %s" % call
+ devfail "Cannot use obsolete :call value '%s' for property '%s'" % [call, self.class.name]
end
return event(name, event)
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 1854c8801..be37c44c8 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -553,6 +553,13 @@ class Type
}
end
+ # If we've got a catalog, then use it to expire our data;
+ # otherwise, null-op.
+ def expire
+ return nil unless expirer
+ super
+ end
+
# Let the catalog determine whether a given cached value is
# still valid or has expired.
def expirer
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 463ea7d9e..7c9afb4ff 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -659,7 +659,8 @@ module Puppet
# Remove any existing data. This is only used when dealing with
# links or directories.
def remove_existing(should)
- return unless s = stat(true)
+ expire()
+ return unless s = stat
self.fail "Could not back up; will not replace" unless handlebackup
diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb
index 635cdc809..6d6dad4f1 100755
--- a/lib/puppet/type/file/content.rb
+++ b/lib/puppet/type/file/content.rb
@@ -80,7 +80,7 @@ module Puppet
def retrieve
return :absent unless stat = @resource.stat
- # Don't even try to manage the content on directories
+ # Don't even try to manage the content on directories or links
return nil if stat.ftype == "directory"
begin
diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb
index a3cf2d4a6..bd2e2fbdd 100755
--- a/lib/puppet/type/file/ensure.rb
+++ b/lib/puppet/type/file/ensure.rb
@@ -110,8 +110,8 @@ module Puppet
end
def change_to_s(currentvalue, newvalue)
- if property = @resource.property(:content) and ! property.insync?(currentvalue)
- return property.change_to_s(currentvalue, property.should)
+ if property = @resource.property(:content) and content = property.retrieve and ! property.insync?(content)
+ return property.change_to_s(content, property.should)
else
super(currentvalue, newvalue)
end
diff --git a/spec/unit/type.rb b/spec/unit/type.rb
index 6f1052516..89a8e5e9c 100755
--- a/spec/unit/type.rb
+++ b/spec/unit/type.rb
@@ -14,6 +14,11 @@ describe Puppet::Type do
resource.expirer.should equal(catalog)
end
+ it "should do nothing when asked to expire when it has no catalog" do
+ resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
+ lambda { resource.expire }.should_not raise_error
+ end
+
it "should be able to retrieve a property by name" do
resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
resource.property(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype))
diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb
index babddec7d..8e55f104c 100755
--- a/test/network/handler/master.rb
+++ b/test/network/handler/master.rb
@@ -23,7 +23,7 @@ class TestMaster < Test::Unit::TestCase
def test_freshness_is_always_now
now1 = mock 'now1'
- Time.expects(:now).returns(now1)
+ Time.stubs(:now).returns(now1)
now1.expects(:to_i).returns 10
diff --git a/test/ral/type/user.rb b/test/ral/type/user.rb
index 02c25ae97..e2629f703 100755
--- a/test/ral/type/user.rb
+++ b/test/ral/type/user.rb
@@ -435,7 +435,7 @@ class TestUser < Test::Unit::TestCase
user[:managehome] = false
end
- assert_raise(ArgumentError, "did not fail when managehome? is false") do
+ assert_raise(Puppet::Error, "did not fail when managehome? is false") do
user[:managehome] = true
end