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 <l...@madstop.com> --- lib/puppet/type/user.rb | 5 +++++ spec/unit/type/user.rb | 6 ++++++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb index 28b1631..2b082ee 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 bf2af23..deabd47 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] -- 1.6.1 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---