Fixing URI issue for design docs
This commit is contained in:
parent
5805f6e27b
commit
3764d1cd5c
|
@ -18,8 +18,8 @@ module CouchRest
|
||||||
self.to_s
|
self.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def design_doc_full_url(db = database)
|
def design_doc_uri(db = database)
|
||||||
"#{db.uri}/#{design_doc_id}"
|
"#{db.root}/#{design_doc_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Retreive the latest version of the design document directly
|
# Retreive the latest version of the design document directly
|
||||||
|
@ -54,10 +54,10 @@ module CouchRest
|
||||||
Thread.current[:couchrest_design_cache] ||= {}
|
Thread.current[:couchrest_design_cache] ||= {}
|
||||||
end
|
end
|
||||||
def design_doc_cache_checksum(db)
|
def design_doc_cache_checksum(db)
|
||||||
design_doc_cache[design_doc_full_url(db)]
|
design_doc_cache[design_doc_uri(db)]
|
||||||
end
|
end
|
||||||
def set_design_doc_cache_checksum(db, checksum)
|
def set_design_doc_cache_checksum(db, checksum)
|
||||||
design_doc_cache[design_doc_full_url(db)] = checksum
|
design_doc_cache[design_doc_uri(db)] = checksum
|
||||||
end
|
end
|
||||||
|
|
||||||
# Writes out a design_doc to a given database if forced
|
# Writes out a design_doc to a given database if forced
|
||||||
|
|
|
@ -50,14 +50,14 @@ describe "Design Documents" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".design_doc_full_url" do
|
describe ".design_doc_uri" do
|
||||||
it "should provide complete url" do
|
it "should provide complete url" do
|
||||||
Article.design_doc_full_url.should eql("#{DB.uri}/_design/Article")
|
Article.design_doc_uri.should eql("#{COUCHHOST}/#{TESTDB}/_design/Article")
|
||||||
end
|
end
|
||||||
it "should provide complete url for new DB" do
|
it "should provide complete url for new DB" do
|
||||||
db = mock("Database")
|
db = mock("Database")
|
||||||
db.should_receive(:uri).and_return('db')
|
db.should_receive(:root).and_return('db')
|
||||||
Article.design_doc_full_url(db).should eql("db/_design/Article")
|
Article.design_doc_uri(db).should eql("db/_design/Article")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue