Signed-off-by: Luke Kanies <[email protected]>
---
lib/puppet/indirector/request.rb | 9 ++++++++-
spec/unit/indirector/request.rb | 4 ++++
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb
index 450b43b..3f7d1c5 100644
--- a/lib/puppet/indirector/request.rb
+++ b/lib/puppet/indirector/request.rb
@@ -9,7 +9,7 @@ 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?
@@ -17,6 +17,13 @@ class Puppet::Indirector::Request
! ! 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
diff --git a/spec/unit/indirector/request.rb b/spec/unit/indirector/request.rb
index e2edc26..241f5f9 100755
--- a/spec/unit/indirector/request.rb
+++ b/spec/unit/indirector/request.rb
@@ -195,6 +195,10 @@ describe Puppet::Indirector::Request do
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")
--
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 [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
-~----------~----~----~----~------~----~------~--~---