[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5-303-gfcfa26a
Max Martin
max at puppetlabs.com
Thu Mar 17 10:47:16 UTC 2011
The following commit has been merged in the upstream branch:
commit d1f1858ea52d3089fd2088994e80d6f49d7e0347
Author: Max Martin <max at puppetlabs.com>
Date: Fri Feb 18 15:19:46 2011 -0800
(#6376) Add support and testing for _search GET requests
Added support for adding "_search" to the end of any indirection to
'pluralize' it, and added tests to check this functionality and to test
hidden side effect of plurality method unpluralizing indirections.
Paired-With:Paul Berry <paul at puppetlabs.com>
diff --git a/lib/puppet/network/http/api/v1.rb b/lib/puppet/network/http/api/v1.rb
index 0a04a46..9e51aae 100644
--- a/lib/puppet/network/http/api/v1.rb
+++ b/lib/puppet/network/http/api/v1.rb
@@ -63,9 +63,9 @@ module Puppet::Network::HTTP::API::V1
return :singular if indirection == "status"
return :plural if indirection == "inventory"
- result = (indirection =~ /s$/) ? :plural : :singular
+ result = (indirection =~ /s$|_search$/) ? :plural : :singular
- indirection.sub!(/s$/, '') if result
+ indirection.sub!(/s$|_search$|es$/, '')
result
end
diff --git a/spec/unit/network/http/api/v1_spec.rb b/spec/unit/network/http/api/v1_spec.rb
index d47fc8d..e734831 100644
--- a/spec/unit/network/http/api/v1_spec.rb
+++ b/spec/unit/network/http/api/v1_spec.rb
@@ -88,6 +88,18 @@ describe Puppet::Network::HTTP::API::V1 do
@tester.uri2indirection("GET", "/env/inventory/search", {}).method.should == :search
end
+ it "should choose 'search' as the indirection method if the http method is a GET and the indirection name is facts_search" do
+ @tester.uri2indirection("GET", "/env/facts_search/bar", {}).method.should == :search
+ end
+
+ it "should change indirection name to 'facts' if the http method is a GET and the indirection name is facts_search" do
+ @tester.uri2indirection("GET", "/env/facts_search/bar", {}).indirection_name.should == :facts
+ end
+
+ it "should change indirection name to 'status' if the http method is a GEt and the indirection name is statuses" do
+ @tester.uri2indirection("GET", "/env/statuses/bar", {}).indirection_name.should == :status
+ end
+
it "should choose 'delete' as the indirection method if the http method is a DELETE and the indirection name is singular" do
@tester.uri2indirection("DELETE", "/env/foo/bar", {}).method.should == :destroy
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list