summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-02 17:14:12 -0600
committerLuke Kanies <luke@madstop.com>2009-02-06 18:08:43 -0600
commit4b7023e97662f944844cb58cd9807c988e4c28e9 (patch)
tree39a93e8c153fe2feb94f362cc3984ccb120f6592
parent8dc0005473ad2b0785919e0bd79ac7d60342625d (diff)
downloadpuppet-4b7023e97662f944844cb58cd9807c988e4c28e9.tar.gz
puppet-4b7023e97662f944844cb58cd9807c988e4c28e9.tar.xz
puppet-4b7023e97662f944844cb58cd9807c988e4c28e9.zip
Fixing (and testing) the return of Indirection#save
This broke in a previous commit, and was apparently not tested well because of how the mocks were set up. The integration test caught it. Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r--lib/puppet/indirector/indirection.rb4
-rwxr-xr-xspec/unit/indirector/indirection.rb16
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index 2eac2395b..18b764757 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -244,10 +244,12 @@ class Puppet::Indirector::Indirection
request = request(:save, instance, *args)
terminus = prepare(request)
- terminus.save(request)
+ result = terminus.save(request)
# If caching is enabled, save our document there
cache.save(request) if cache?
+
+ result
end
private
diff --git a/spec/unit/indirector/indirection.rb b/spec/unit/indirector/indirection.rb
index 51bd45473..84b4e0e24 100755
--- a/spec/unit/indirector/indirection.rb
+++ b/spec/unit/indirector/indirection.rb
@@ -351,9 +351,9 @@ describe Puppet::Indirector::Indirection do
it_should_behave_like "Indirection Delegator"
it_should_behave_like "Delegation Authorizer"
- it "should return nil" do
- @terminus.stubs(:save)
- @indirection.save(@instance).should be_nil
+ it "should return the result of the save" do
+ @terminus.stubs(:save).returns "foo"
+ @indirection.save(@instance).should == "foo"
end
describe "when caching is enabled" do
@@ -364,6 +364,16 @@ describe Puppet::Indirector::Indirection do
@instance.stubs(:expired?).returns false
end
+ it "should return the result of saving to the terminus" do
+ request = stub 'request', :instance => @instance, :node => nil
+
+ @indirection.expects(:request).returns request
+
+ @cache.stubs(:save)
+ @terminus.stubs(:save).returns @instance
+ @indirection.save(@instance).should equal(@instance)
+ end
+
it "should use a request to save the object to the cache" do
request = stub 'request', :instance => @instance, :node => nil