diff options
| -rw-r--r-- | lib/puppet/metatype/metaparams.rb | 8 | ||||
| -rwxr-xr-x | test/ral/manager/attributes.rb | 30 |
2 files changed, 36 insertions, 2 deletions
diff --git a/lib/puppet/metatype/metaparams.rb b/lib/puppet/metatype/metaparams.rb index ede201ff4..7f0a1ef01 100644 --- a/lib/puppet/metatype/metaparams.rb +++ b/lib/puppet/metatype/metaparams.rb @@ -80,8 +80,12 @@ class Puppet::Type next if @resource.propertydefined?(property) unless propertyklass = @resource.class.validproperty?(property) - raise Puppet::Error, "%s is not a valid attribute for %s" % - [property, self.class.name] + if @resource.class.validattr?(property) + next + else + raise Puppet::Error, "%s is not a valid attribute for %s" % + [property, self.class.name] + end end next unless propertyklass.checkable? @resource.newattr(property) diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb index 5a5064129..273dc6844 100755 --- a/test/ral/manager/attributes.rb +++ b/test/ral/manager/attributes.rb @@ -285,6 +285,36 @@ class TestTypeAttributes < Test::Unit::TestCase @logs.clear end end + + # Make sure the 'check' metaparam just ignores non-properties, rather than failing. + def test_check_allows_parameters + file = Puppet::Type.type(:file) + klass = file.attrclass(:check) + + resource = file.create(:path => tempfile) + inst = klass.new(:resource => resource) + + {:property => [:owner, :group], :parameter => [:ignore, :recurse], :metaparam => [:require, :subscribe]}.each do |attrtype, attrs| + assert_nothing_raised("Could not set check to a single %s value" % attrtype) do + inst.value = attrs[0] + end + + if attrtype == :property + assert(resource.property(attrs[0]), "Check did not create property instance during single check") + end + assert_nothing_raised("Could not set check to multiple %s values" % attrtype) do + inst.value = attrs + end + if attrtype == :property + assert(resource.property(attrs[1]), "Check did not create property instance during multiple check") + end + end + + # But make sure actually invalid attributes fail + assert_raise(Puppet::Error, ":check did not fail on invalid attribute") do + inst.value = :nosuchattr + end + end end # $Id$ |
