PUT to update
This commit is contained in:
parent
e7ea12f2ae
commit
43f51c5490
3
deps/rest-client/lib/rest_client.rb
vendored
3
deps/rest-client/lib/rest_client.rb
vendored
|
@ -57,7 +57,8 @@ module RestClient
|
||||||
|
|
||||||
def execute_inner
|
def execute_inner
|
||||||
uri = parse_url(url)
|
uri = parse_url(url)
|
||||||
transmit uri, net_http_class(method).new(uri.path, make_headers(headers)), payload
|
uri_path = uri.respond_to?(:request_uri) ? uri.request_uri : uri.path
|
||||||
|
transmit uri, net_http_class(method).new(uri_path, make_headers(headers)), payload
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_headers(user_headers)
|
def make_headers(user_headers)
|
||||||
|
|
|
@ -69,6 +69,22 @@ describe CouchRest::Database do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "PUT (existing document with rev)" do
|
||||||
|
before(:each) do
|
||||||
|
@db.save({'_id' => 'my-doc', 'will-exist' => 'here'})
|
||||||
|
@doc = @db.get('my-doc')
|
||||||
|
end
|
||||||
|
it "should start with the document" do
|
||||||
|
@doc['will-exist'].should == 'here'
|
||||||
|
end
|
||||||
|
it "should update the document" do
|
||||||
|
@doc['them-keys'] = 'huge'
|
||||||
|
@db.save(@doc)
|
||||||
|
now = @db.get('my-doc')
|
||||||
|
now['them-keys'].should == 'huge'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "DELETE existing document" do
|
describe "DELETE existing document" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@r = @db.save({'lemons' => 'from texas', 'and' => 'spain'})
|
@r = @db.save({'lemons' => 'from texas', 'and' => 'spain'})
|
||||||
|
@ -81,6 +97,11 @@ describe CouchRest::Database do
|
||||||
@db.delete doc
|
@db.delete doc
|
||||||
lambda{@db.get @r['id']}.should raise_error
|
lambda{@db.get @r['id']}.should raise_error
|
||||||
end
|
end
|
||||||
|
it "should work with uri id" do
|
||||||
|
doc = @db.get(@docid)
|
||||||
|
@db.delete doc
|
||||||
|
lambda{@db.get @docid}.should raise_error
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should list documents" do
|
it "should list documents" do
|
||||||
|
|
Loading…
Reference in a new issue