diff --git a/deps/rest-client/lib/rest_client.rb b/deps/rest-client/lib/rest_client.rb index 6e8ff8f..c852963 100644 --- a/deps/rest-client/lib/rest_client.rb +++ b/deps/rest-client/lib/rest_client.rb @@ -57,7 +57,8 @@ module RestClient def execute_inner 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 def make_headers(user_headers) diff --git a/spec/database_spec.rb b/spec/database_spec.rb index c04f3ca..97d766e 100644 --- a/spec/database_spec.rb +++ b/spec/database_spec.rb @@ -69,6 +69,22 @@ describe CouchRest::Database do 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 before(:each) do @r = @db.save({'lemons' => 'from texas', 'and' => 'spain'}) @@ -81,6 +97,11 @@ describe CouchRest::Database do @db.delete doc lambda{@db.get @r['id']}.should raise_error end + it "should work with uri id" do + doc = @db.get(@docid) + @db.delete doc + lambda{@db.get @docid}.should raise_error + end end it "should list documents" do