Skip to content

Commit d19d716

Browse files
author
AJ Christensen
committed
CHEF-222: chef 0.9 compat without client trying to connect to the couch server
Removed private method specifications Shifted CouchDB version detection into view_uri
1 parent 5081a15 commit d19d716

3 files changed

Lines changed: 3 additions & 37 deletions

File tree

chef/lib/chef/config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class Config
6262
:template_url => "http://localhost:4000",
6363
:remotefile_url => "http://localhost:4000",
6464
:search_url => "http://localhost:4000",
65-
:couchdb_database => "chef",
6665
:couchdb_version => nil,
66+
:couchdb_database => "chef",
6767
:openid_store_couchdb => false,
6868
:openid_cstore_couchdb => false,
6969
:openid_store_path => "/var/chef/openid/db",

chef/lib/chef/couchdb.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
class Chef
2626
class CouchDB
2727
include Chef::Mixin::ParamsValidate
28-
28+
2929
def initialize(url=nil)
3030
url ||= Chef::Config[:couchdb_url]
3131
@rest = Chef::REST.new(url)
32-
Chef::Config[:couchdb_version] ||= @rest.run_request(:GET, URI.parse(@rest.url + "/"), false, 10, false)["version"].gsub(/-.+/,"").to_f
3332
end
3433

3534
def create_db
@@ -152,6 +151,7 @@ def safe_name(name)
152151
end
153152

154153
def view_uri(design, view)
154+
Chef::Config[:couchdb_version] ||= @rest.run_request(:GET, URI.parse(@rest.url + "/"), false, 10, false)["version"].gsub(/-.+/,"").to_f
155155
case Chef::Config[:couchdb_version]
156156
when 0.9
157157
"#{Chef::Config[:couchdb_database]}/_design/#{design}/_view/#{view}"

chef/spec/unit/couchdb_spec.rb

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636
Chef::REST.should_receive(:new).with("http://monkeypants")
3737
Chef::CouchDB.new("http://monkeypants")
3838
end
39-
40-
it "should parse the CouchDB version number" do
41-
42-
end
4339
end
4440

4541
describe Chef::CouchDB, "create_db" do
@@ -262,34 +258,4 @@ def do_delete(rev=nil)
262258
@couchdb.should_receive(:safe_name).with("asdf.lol.com").and_return("asdf_lol_com")
263259
@couchdb.safe_name("asdf.lol.com")
264260
end
265-
end
266-
267-
describe Chef::CouchDB, "view_uri" do
268-
before do
269-
@couchdb = mock("Chef::CouchDB", :null_object => true)
270-
Chef::CouchDB.stub!(:new).and_return(@couchdb)
271-
Chef::Config.stub!(:[]).with(:couchdb_database).and_return("chef")
272-
end
273-
274-
describe "on couchdb 0.8" do
275-
before do
276-
Chef::Config.stub!(:[]).with(:couchdb_version).and_return(0.8)
277-
end
278-
279-
it "should output an appropriately formed view URI" do
280-
@couchdb.should_receive(:view_uri).with("nodes", "all").and_return("chef/_view/nodes/all")
281-
@couchdb.view_uri("nodes", "all")
282-
end
283-
end
284-
285-
describe "on couchdb 0.9" do
286-
before do
287-
Chef::Config.stub!(:[]).with(:couchdb_version).and_return(0.9)
288-
end
289-
290-
it "should output an appropriately formed view URI" do
291-
@couchdb.should_receive(:view_uri).with("nodes", "all").and_return("chef/_design/nodes/_view/all")
292-
@couchdb.view_uri("nodes", "all")
293-
end
294-
end
295261
end

0 commit comments

Comments
 (0)