Fixing incorrectly generated document URIs with testing
Signed-off-by: Marcos Tapajós <tapajos@gmail.com>
This commit is contained in:
parent
118c944b85
commit
08cf9e59b6
|
@ -65,7 +65,7 @@ module CouchRest
|
||||||
# Returns the CouchDB uri for the document
|
# Returns the CouchDB uri for the document
|
||||||
def uri(append_rev = false)
|
def uri(append_rev = false)
|
||||||
return nil if new?
|
return nil if new?
|
||||||
couch_uri = "http://#{database.root}/#{CGI.escape(id)}"
|
couch_uri = "#{database.root}/#{CGI.escape(id)}"
|
||||||
if append_rev == true
|
if append_rev == true
|
||||||
couch_uri << "?rev=#{rev}"
|
couch_uri << "?rev=#{rev}"
|
||||||
elsif append_rev.kind_of?(Integer)
|
elsif append_rev.kind_of?(Integer)
|
||||||
|
|
|
@ -83,6 +83,14 @@ describe CouchRest::Document do
|
||||||
@doc.id.should == @resp["id"]
|
@doc.id.should == @resp["id"]
|
||||||
@doc.rev.should == @resp["rev"]
|
@doc.rev.should == @resp["rev"]
|
||||||
end
|
end
|
||||||
|
it "should generate a correct URI" do
|
||||||
|
@doc.uri.should == "#{@db.root}/#{@doc.id}"
|
||||||
|
URI.parse(@doc.uri).to_s.should == @doc.uri
|
||||||
|
end
|
||||||
|
it "should generate a correct URI with revision" do
|
||||||
|
@doc.uri(true).should == "#{@db.root}/#{@doc.id}?rev=#{@doc.rev}"
|
||||||
|
URI.parse(@doc.uri(true)).to_s.should == @doc.uri(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "bulk saving" do
|
describe "bulk saving" do
|
||||||
|
|
Loading…
Reference in a new issue