summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-04-13 19:20:40 -0700
committerNick Lewis <nick@puppetlabs.com>2011-04-13 19:20:40 -0700
commitc7ae6bde57fd3ab8380cd5804fd87283bb708755 (patch)
treec0712b1ac2b936fd5a3a2ea0da6c9a976c1cb7d2
parent3ab44c7ce01ab86a995deb66228f5be95239c92a (diff)
parent9bc4bcefb1a9f2545b4828dcea7a41ef450e7d52 (diff)
downloadpuppet-c7ae6bde57fd3ab8380cd5804fd87283bb708755.tar.gz
puppet-c7ae6bde57fd3ab8380cd5804fd87283bb708755.tar.xz
puppet-c7ae6bde57fd3ab8380cd5804fd87283bb708755.zip
Merge branch 'ticket/next/7103' into next
-rw-r--r--lib/puppet/network/http/handler.rb8
-rwxr-xr-xspec/unit/network/http/handler_spec.rb18
2 files changed, 11 insertions, 15 deletions
diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb
index 2b9e81b61..2c78a0283 100644
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@ -122,10 +122,10 @@ module Puppet::Network::HTTP::Handler
end
# Execute our head.
- def do_head(indirection_request, request, response)
- unless indirection_request.model.head(indirection_request.key, indirection_request.to_hash)
- Puppet.info("Could not find #{indirection_request.indirection_name} for '#{indirection_request.key}'")
- return do_exception(response, "Could not find #{indirection_request.indirection_name} #{indirection_request.key}", 404)
+ def do_head(indirection_name, key, params, request, response)
+ unless self.model(indirection_name).indirection.head(key, params)
+ Puppet.info("Could not find #{indirection_name} for '#{key}'")
+ return do_exception(response, "Could not find #{indirection_name} #{key}", 404)
end
# No need to set a response because no response is expected from a
diff --git a/spec/unit/network/http/handler_spec.rb b/spec/unit/network/http/handler_spec.rb
index 83969c504..c709d82fe 100755
--- a/spec/unit/network/http/handler_spec.rb
+++ b/spec/unit/network/http/handler_spec.rb
@@ -240,34 +240,30 @@ describe Puppet::Network::HTTP::Handler do
describe "when performing head operation" do
before do
- @irequest = stub 'indirection_request', :method => :head, :indirection_name => "my_handler", :to_hash => {}, :key => "my_result", :model => @model_class
+ @handler.stubs(:model).with("my_handler").returns(stub 'model', :indirection => @model_class)
+ @handler.stubs(:http_method).with(@request).returns("HEAD")
+ @handler.stubs(:path).with(@request).returns("/production/my_handler/my_result")
+ @handler.stubs(:params).with(@request).returns({})
@model_class.stubs(:head).returns true
end
- it "should use the indirection request to find the model class" do
- @irequest.expects(:model).returns @model_class
-
- @handler.do_head(@irequest, @request, @response)
- end
-
it "should use the escaped request key" do
@model_class.expects(:head).with do |key, args|
key == "my_result"
end.returns true
- @handler.do_head(@irequest, @request, @response)
+ @handler.process(@request, @response)
end
it "should not generate a response when a model head call succeeds" do
@handler.expects(:set_response).never
- @handler.do_head(@irequest, @request, @response)
+ @handler.process(@request, @response)
end
it "should return a 404 when the model head call returns false" do
- @model_class.stubs(:name).returns "my name"
@handler.expects(:set_response).with { |response, body, status| status == 404 }
@model_class.stubs(:head).returns(false)
- @handler.do_head(@irequest, @request, @response)
+ @handler.process(@request, @response)
end
end