updated specs and code to reflect changes in bulk_docs for CouchDB 0.7.3
This commit is contained in:
parent
c3b6e3e2d0
commit
81d27c6f16
|
@ -37,7 +37,7 @@ class CouchRest
|
||||||
end
|
end
|
||||||
|
|
||||||
def bulk_save docs
|
def bulk_save docs
|
||||||
CouchRest.post "#{@root}/_bulk_docs", docs
|
CouchRest.post "#{@root}/_bulk_docs", {:docs => docs}
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete doc
|
def delete doc
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe CouchRest do
|
||||||
@cr.databases.should be_an_instance_of(Array)
|
@cr.databases.should be_an_instance_of(Array)
|
||||||
end
|
end
|
||||||
it "should get info" do
|
it "should get info" do
|
||||||
@cr.info.should == {"couchdb"=>"Welcome", "version"=>"0.0.0"}
|
@cr.info["couchdb"].should == "Welcome"
|
||||||
@cr.info.class.should == Hash
|
@cr.info.class.should == Hash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -70,7 +70,7 @@ describe CouchRest::Database do
|
||||||
{"mild" => "yet local"},
|
{"mild" => "yet local"},
|
||||||
{"another" => ["set","of","keys"]}
|
{"another" => ["set","of","keys"]}
|
||||||
])
|
])
|
||||||
rs['results'].each do |r|
|
rs['new_revs'].each do |r|
|
||||||
@db.get(r['id'])
|
@db.get(r['id'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -80,33 +80,25 @@ describe CouchRest::Database do
|
||||||
{"_id" => "twoB", "mild" => "yet local"},
|
{"_id" => "twoB", "mild" => "yet local"},
|
||||||
{"another" => ["set","of","keys"]}
|
{"another" => ["set","of","keys"]}
|
||||||
])
|
])
|
||||||
rs['results'].each do |r|
|
rs['new_revs'].each do |r|
|
||||||
@db.get(r['id'])
|
@db.get(r['id'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
it "should with one bad id should save the ones it can" do
|
it "in the case of an id conflict should not insert anything" do
|
||||||
@r = @db.save({'lemons' => 'from texas', 'and' => 'how', "_id" => "oneB"})
|
@r = @db.save({'lemons' => 'from texas', 'and' => 'how', "_id" => "oneB"})
|
||||||
|
|
||||||
|
lambda do
|
||||||
rs = @db.bulk_save([
|
rs = @db.bulk_save([
|
||||||
{"_id" => "oneB", "wild" => "and random"},
|
{"_id" => "oneB", "wild" => "and random"},
|
||||||
{"_id" => "twoB", "mild" => "yet local"},
|
{"_id" => "twoB", "mild" => "yet local"},
|
||||||
{"another" => ["set","of","keys"]}
|
{"another" => ["set","of","keys"]}
|
||||||
])
|
])
|
||||||
|
end.should raise_error(RestClient::Request::RequestFailed)
|
||||||
# should save the new document
|
|
||||||
newid = @db.documents['rows'].reject do |d|
|
lambda do
|
||||||
['oneB','twoB'].include?(d['id'])
|
@db.get('twoB')
|
||||||
end.first['id']
|
end.should raise_error(RestClient::Request::RequestFailed)
|
||||||
newdoc = @db.get(newid)
|
|
||||||
newdoc["another"][2].should == 'keys'
|
|
||||||
|
|
||||||
# should save the ok id
|
|
||||||
@db.get('twoB')['mild'].should == "yet local"
|
|
||||||
|
|
||||||
# should confict on the duplicate id
|
|
||||||
oneB = @db.get('oneB')
|
|
||||||
oneB['wild'].should be_nil
|
|
||||||
oneB['lemons'].should == 'from texas'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue