From 5ee660276f3e4f6519b1257673fa690be0416fbd Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 19 Aug 2009 17:04:20 -0700 Subject: Adding an 'exists?' delegator from user type to provider We need this knowledge from the Settings class, and it makes more sense to delegate than to use direct access to the provider. Signed-off-by: Luke Kanies --- lib/puppet/type/user.rb | 5 +++++ spec/unit/type/user.rb | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb index 28b1631cb..2b082ee94 100755 --- a/lib/puppet/type/user.rb +++ b/lib/puppet/type/user.rb @@ -245,6 +245,11 @@ module Puppet autos end + # Provide an external hook. Yay breaking out of APIs. + def exists? + provider.exists? + end + def retrieve absent = false properties().inject({}) { |prophash, property| diff --git a/spec/unit/type/user.rb b/spec/unit/type/user.rb index bf2af23ab..deabd4746 100755 --- a/spec/unit/type/user.rb +++ b/spec/unit/type/user.rb @@ -41,6 +41,12 @@ describe user do it "should have a valid provider" do user.new(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider) end + + it "should delegate existence questions to its provider" do + instance = user.new(:name => "foo") + instance.provider.expects(:exists?).returns "eh" + instance.exists?.should == "eh" + end end properties = [:ensure, :uid, :gid, :home, :comment, :shell, :password, :groups, :roles, :auths, :profiles, :project, :keys] -- cgit