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
This commit is contained in:
Geoff Buesing 2009-03-18 11:22:49 -05:00
parent 76ef427862
commit 4d8314124b
4 changed files with 0 additions and 113 deletions

View file

@ -171,10 +171,6 @@ module CouchRest
def copy uri, destination def copy uri, destination
JSON.parse(RestClient.copy(uri, {'Destination' => destination})) JSON.parse(RestClient.copy(uri, {'Destination' => destination}))
end end
def move uri, destination
JSON.parse(RestClient.move(uri, {'Destination' => destination}))
end
def paramify_url url, params = {} def paramify_url url, params = {}
if params && !params.empty? if params && !params.empty?

View file

@ -224,26 +224,6 @@ module CouchRest
copy_doc(doc, dest) copy_doc(doc, dest)
end end
# MOVE an existing document to a new id. If the destination id currently exists, a rev must be provided.
# <tt>dest</tt> 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. # Compact the database, removing old document revisions and optimizing space use.
def compact! def compact!
CouchRest.post "#{@uri}/_compact" CouchRest.post "#{@uri}/_compact"

View file

@ -554,50 +554,6 @@ describe CouchRest::Database do
end end
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 it "should list documents" do
5.times do 5.times do

View file

@ -199,51 +199,6 @@ describe CouchRest::Document do
end end
end 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 end
describe "dealing with attachments" do describe "dealing with attachments" do