This fixes spec and unit tests indirectly related to the previous
patch/revert.
One failure was from trying to test the User Type's roles, when,
on many platforms, the roles feature wasn't supported by the default
Provider.
Other tests could fail on some platforms because they assumed that
unsupported attributes would be ignored with a warning, but the code was
crashing instead (I don't think this would create a user-observable bug,
but I'm not certain.)

Signed-off-by: Jesse Wolfe <[email protected]>
---
 lib/puppet/type.rb          |   16 +++++++++-------
 spec/unit/type/user_spec.rb |    5 +++++
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index ccb2b49..f9aacec 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -410,13 +410,15 @@ class Type
 
     property = self.newattr(name)
 
-    begin
-      # make sure the parameter doesn't have any errors
-      property.value = value
-    rescue => detail
-      error = Puppet::Error.new("Parameter #{name} failed: #{detail}")
-      error.set_backtrace(detail.backtrace)
-      raise error
+    if property
+      begin
+        # make sure the parameter doesn't have any errors
+        property.value = value
+      rescue => detail
+        error = Puppet::Error.new("Parameter #{name} failed: #{detail}")
+        error.set_backtrace(detail.backtrace)
+        raise error
+      end
     end
 
     nil
diff --git a/spec/unit/type/user_spec.rb b/spec/unit/type/user_spec.rb
index abe1893..4c6eb11 100755
--- a/spec/unit/type/user_spec.rb
+++ b/spec/unit/type/user_spec.rb
@@ -262,6 +262,11 @@ describe user do
   end
 
   describe "when user has roles" do
+    before do
+      # To test this feature, we have to support it.
+      user.new(:name => "foo").provider.class.stubs(:feature?).returns(true)
+    end
+
     it "should autorequire roles" do
       testuser = Puppet::Type.type(:user).new(:name => "testuser")
       testuser[:roles] = "testrole"
-- 
1.7.0.4

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to