From 4d8314124b664e7f632dbfb791dde9f49e91b767 Mon Sep 17 00:00:00 2001 From: Geoff Buesing Date: Wed, 18 Mar 2009 11:22:49 -0500 Subject: [PATCH] Remove CouchRest.move, CouchRest::Database#move and #move_doc, because these methods are no longer supported by CouchDB Ref: http://n2.nabble.com/Removing-MOVE-td2490780.html#a2490780 --- lib/couchrest.rb | 4 --- lib/couchrest/core/database.rb | 20 ------------- spec/couchrest/core/database_spec.rb | 44 --------------------------- spec/couchrest/core/document_spec.rb | 45 ---------------------------- 4 files changed, 113 deletions(-) diff --git a/lib/couchrest.rb b/lib/couchrest.rb index a32e17b..4cbe6af 100644 --- a/lib/couchrest.rb +++ b/lib/couchrest.rb @@ -171,10 +171,6 @@ module CouchRest def copy uri, destination JSON.parse(RestClient.copy(uri, {'Destination' => destination})) end - - def move uri, destination - JSON.parse(RestClient.move(uri, {'Destination' => destination})) - end def paramify_url url, params = {} if params && !params.empty? diff --git a/lib/couchrest/core/database.rb b/lib/couchrest/core/database.rb index 82fba7d..7f4fd41 100644 --- a/lib/couchrest/core/database.rb +++ b/lib/couchrest/core/database.rb @@ -224,26 +224,6 @@ module CouchRest copy_doc(doc, dest) end - # MOVE an existing document to a new id. If the destination id currently exists, a rev must be provided. - # dest can take one of two forms if overwriting: "id_to_overwrite?rev=revision" or the actual doc - # hash with a '_rev' key - def move_doc(doc, dest) - raise ArgumentError, "_id and _rev are required for moving" unless doc['_id'] && doc['_rev'] - slug = escape_docid(doc['_id']) - destination = if dest.respond_to?(:has_key?) && dest['_id'] && dest['_rev'] - "#{dest['_id']}?rev=#{dest['_rev']}" - else - dest - end - CouchRest.move "#{@uri}/#{slug}?rev=#{doc['_rev']}", destination - end - - ### DEPRECATION NOTICE - def move(doc, dest) - puts "CouchRest::Database's move method is being deprecated, please use move_doc instead" - move_doc(doc, dest) - end - # Compact the database, removing old document revisions and optimizing space use. def compact! CouchRest.post "#{@uri}/_compact" diff --git a/spec/couchrest/core/database_spec.rb b/spec/couchrest/core/database_spec.rb index e7f03cc..d0a1eb8 100644 --- a/spec/couchrest/core/database_spec.rb +++ b/spec/couchrest/core/database_spec.rb @@ -554,50 +554,6 @@ describe CouchRest::Database do end end - describe "MOVE existing document" do - before :each do - @r = @db.save_doc({'artist' => 'Zappa', 'title' => 'Muffin Man'}) - @docid = 'tracks/zappa/muffin-man' - @doc = @db.get(@r['id']) - end - describe "to a new location" do - it "should work" do - @db.move_doc @doc, @docid - newdoc = @db.get(@docid) - newdoc['artist'].should == 'Zappa' - lambda {@db.get(@r['id'])}.should raise_error(RestClient::ResourceNotFound) - end - it "should fail without an _id or _rev" do - lambda{@db.move({"not"=>"a real doc"})}.should raise_error(ArgumentError) - lambda{@db.move({"_id"=>"not a real doc"})}.should raise_error(ArgumentError) - end - end - describe "to an existing location" do - before :each do - @db.save_doc({'_id' => @docid, 'will-exist' => 'here'}) - end - it "should fail without a rev" do - @doc.delete("_rev") - lambda{@db.move_doc @doc, @docid}.should raise_error(ArgumentError) - lambda{@db.get(@r['id'])}.should_not raise_error - end - it "should succeed with a rev" do - @to_be_overwritten = @db.get(@docid) - @db.move_doc @doc, "#{@docid}?rev=#{@to_be_overwritten['_rev']}" - newdoc = @db.get(@docid) - newdoc['artist'].should == 'Zappa' - lambda {@db.get(@r['id'])}.should raise_error(RestClient::ResourceNotFound) - end - it "should succeed given the doc to overwrite" do - @to_be_overwritten = @db.get(@docid) - @db.move_doc @doc, @to_be_overwritten - newdoc = @db.get(@docid) - newdoc['artist'].should == 'Zappa' - lambda {@db.get(@r['id'])}.should raise_error(RestClient::ResourceNotFound) - end - end - end - it "should list documents" do 5.times do diff --git a/spec/couchrest/core/document_spec.rb b/spec/couchrest/core/document_spec.rb index da76714..e83c05f 100644 --- a/spec/couchrest/core/document_spec.rb +++ b/spec/couchrest/core/document_spec.rb @@ -199,51 +199,6 @@ describe CouchRest::Document do end end end - - describe "MOVE existing document" do - before :each do - @db = reset_test_db! - @resp = @db.save_doc({'key' => 'value'}) - @docid = 'new-location' - @doc = @db.get(@resp['id']) - end - describe "to a new location" do - it "should work" do - @doc.move @docid - newdoc = @db.get(@docid) - newdoc['key'].should == 'value' - lambda {@db.get(@resp['id'])}.should raise_error(RestClient::ResourceNotFound) - end - it "should fail without a database" do - lambda{CouchRest::Document.new({"not"=>"a real doc"}).move}.should raise_error(ArgumentError) - lambda{CouchRest::Document.new({"_id"=>"not a real doc"}).move}.should raise_error(ArgumentError) - end - end - describe "to an existing location" do - before :each do - @db.save_doc({'_id' => @docid, 'will-exist' => 'here'}) - end - it "should fail without a rev" do - @doc.delete("_rev") - lambda{@doc.move @docid}.should raise_error(ArgumentError) - lambda{@db.get(@resp['id'])}.should_not raise_error - end - it "should succeed with a rev" do - @to_be_overwritten = @db.get(@docid) - @doc.move "#{@docid}?rev=#{@to_be_overwritten['_rev']}" - newdoc = @db.get(@docid) - newdoc['key'].should == 'value' - lambda {@db.get(@resp['id'])}.should raise_error(RestClient::ResourceNotFound) - end - it "should succeed given the doc to overwrite" do - @to_be_overwritten = @db.get(@docid) - @doc.move @to_be_overwritten - newdoc = @db.get(@docid) - newdoc['key'].should == 'value' - lambda {@db.get(@resp['id'])}.should raise_error(RestClient::ResourceNotFound) - end - end - end end describe "dealing with attachments" do