Merge branch 'master' of git://github.com/mattly/couchrest into mattly/master

This commit is contained in:
Chris Anderson 2008-06-12 09:11:47 -07:00
commit b5a11407d9
2 changed files with 25 additions and 0 deletions

View file

@ -70,6 +70,7 @@ class CouchRest
private
def encode_attachments attachments
attachments.each do |k,v|
next if v['stub']
v['data'] = base64(v['data'])
end
attachments

View file

@ -207,6 +207,30 @@ describe CouchRest::Database do
attachment.should == @attach
end
end
describe "PUT document with attachment stub" do
before(:each) do
@attach = "<html><head><title>My Doc</title></head><body><p>Has words.</p></body></html>"
doc = {
'_id' => 'mydocwithattachment',
'field' => ['some_value'],
'_attachments' => {
'test.html' => {
'type' => 'text/html', 'data' => @attach
}
}
}
@db.save(doc)
doc = @db.get('mydocwithattachment')
doc['field'] << 'another value'
@db.save(doc)
end
it 'should be there' do
attachment = @db.fetch_attachment('mydocwithattachment', 'test.html')
attachment.should == @attach
end
end
describe "PUT document with multiple attachments" do
before(:each) do