Permalink
Browse files

Requests now use default environment when none is specified

Signed-off-by: Luke Kanies <luke@madstop.com>
  • Loading branch information...
1 parent 15740fe commit b6116fe28d9c771dbe2dcded539bcf30eea552a3 @lak lak committed with jamtur01 Mar 13, 2009
Showing with 12 additions and 1 deletion.
  1. +8 −1 lib/puppet/indirector/request.rb
  2. +4 −0 spec/unit/indirector/request.rb
@@ -9,14 +9,21 @@ class Puppet::Indirector::Request
attr_accessor :server, :port, :uri, :protocol
- attr_reader :environment, :indirection_name
+ attr_reader :indirection_name
# Is this an authenticated request?
def authenticated?
# Double negative, so we just get true or false
! ! authenticated
end
+ def environment
+ unless defined?(@environment) and @environment
+ @environment = Puppet::Node::Environment.new()
+ end
+ @environment
+ end
+
def environment=(env)
@environment = if env.is_a?(Puppet::Node::Environment)
env
@@ -195,6 +195,10 @@
Puppet::Indirector::Request.new(:myind, :find, "my key", :environment => env).environment.should equal(env)
end
+ it "should use the default environment when none is provided" do
+ Puppet::Indirector::Request.new(:myind, :find, "my key" ).environment.should equal(Puppet::Node::Environment.new)
+ end
+
describe "when building a query string from its options" do
before do
@request = Puppet::Indirector::Request.new(:myind, :find, "my key")

0 comments on commit b6116fe

Please sign in to comment.