summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXabier de Zuazo <xabier@onddo.com>2013-12-16 23:05:48 +0100
committerXabier de Zuazo <xabier@onddo.com>2013-12-16 23:05:48 +0100
commit688f95845e0eb7d61f32587da9b9050d42b520cf (patch)
tree9e5bf6326de4773d7ed192cfc9920f3d8a6558b0
parentecbc917ac5496f3138b798332ea66f477c33f8ba (diff)
downloadchef-688f95845e0eb7d61f32587da9b9050d42b520cf.tar.gz
CHEF-4762: http_request with action :head does not behave correctly in 11.8.0 fixed
-rw-r--r--lib/chef/provider/http_request.rb2
-rw-r--r--spec/unit/provider/http_request_spec.rb14
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/chef/provider/http_request.rb b/lib/chef/provider/http_request.rb
index 1e0aa8b4a0..e45d2336bb 100644
--- a/lib/chef/provider/http_request.rb
+++ b/lib/chef/provider/http_request.rb
@@ -44,7 +44,7 @@ class Chef
Chef::Log.info("#{@new_resource} HEAD to #{@new_resource.url} successful")
Chef::Log.debug("#{@new_resource} HEAD request response: #{modified}")
# :head is usually used to trigger notifications, which converge_by now does
- if modified
+ if modified != false
converge_by("#{@new_resource} HEAD to #{@new_resource.url} returned modified, trigger notifications") {}
end
end
diff --git a/spec/unit/provider/http_request_spec.rb b/spec/unit/provider/http_request_spec.rb
index e8ce5f9ae3..0dba30405c 100644
--- a/spec/unit/provider/http_request_spec.rb
+++ b/spec/unit/provider/http_request_spec.rb
@@ -110,17 +110,29 @@ describe Chef::Provider::HttpRequest do
it "should inflate a message block at runtime" do
@new_resource.message { "return" }
- @http.should_receive(:head).with("http://www.opscode.com/?message=return", {}).and_return("")
+ @http.should_receive(:head).with("http://www.opscode.com/?message=return", {}).and_return(nil)
@provider.run_action(:head)
@new_resource.should be_updated
end
it "should run a HEAD request" do
+ @http.should_receive(:head).with("http://www.opscode.com/?message=is cool", {}).and_return(nil)
+ @provider.run_action(:head)
+ @new_resource.should be_updated
+ end
+
+ it "should update a HEAD request with empty string response body (CHEF-4762)" do
@http.should_receive(:head).with("http://www.opscode.com/?message=is cool", {}).and_return("")
@provider.run_action(:head)
@new_resource.should be_updated
end
+ it "should update a HEAD request with nil response body (CHEF-4762)" do
+ @http.should_receive(:head).with("http://www.opscode.com/?message=is cool", {}).and_return(nil)
+ @provider.run_action(:head)
+ @new_resource.should be_updated
+ end
+
it "should run a HEAD request with If-Modified-Since header" do
@new_resource.headers "If-Modified-Since" => File.mtime(__FILE__).httpdate
@http.should_receive(:head).with("http://www.opscode.com/?message=is cool", @new_resource.headers)