diff options
author | Jeremiah Snapp <jeremiah.snapp@opscode.com> | 2013-08-15 15:04:56 -0400 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2013-10-04 09:52:10 -0700 |
commit | d3e9bbb6bd569b06ee270dfa446590499e1304f2 (patch) | |
tree | c8a43fea0e1ac6963f47dc12023c9b15c8d4250c /spec/unit/data_bag_spec.rb | |
parent | 2546fbd5251c8feaad5b7b715ffbe67b335359d8 (diff) | |
download | chef-d3e9bbb6bd569b06ee270dfa446590499e1304f2.tar.gz |
Make Chef::DataBag.save use POST instead of PUT
PUT doesn't make sense in DataBag context since you can't update a data bag.
Chef::DataBag.save should rescue a 409 response since that indicates the data
bag already exists.
Diffstat (limited to 'spec/unit/data_bag_spec.rb')
-rw-r--r-- | spec/unit/data_bag_spec.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb index d8ad535915..9fbdc64d98 100644 --- a/spec/unit/data_bag_spec.rb +++ b/spec/unit/data_bag_spec.rb @@ -76,14 +76,13 @@ describe Chef::DataBag do Chef::REST.stub!(:new).and_return(@rest) end - it "should update the data bag when it already exists" do - @rest.should_receive(:put_rest).with("data/piggly_wiggly", @data_bag) + it "should silently proceed when the data bag already exists" do + exception = mock("409 error", :code => "409") + @rest.should_receive(:post_rest).and_raise(Net::HTTPServerException.new("foo", exception)) @data_bag.save end - it "should create the data bag when it is not found" do - exception = mock("404 error", :code => "404") - @rest.should_receive(:put_rest).and_raise(Net::HTTPServerException.new("foo", exception)) + it "should create the data bag" do @rest.should_receive(:post_rest).with("data", @data_bag) @data_bag.save end @@ -96,7 +95,6 @@ describe Chef::DataBag do Chef::Config[:why_run] = false end it "should not save" do - @rest.should_not_receive(:put_rest) @rest.should_not_receive(:post_rest) @data_bag.save end |