PUT attachments as stubs doesnt choke
This commit is contained in:
parent
170e61f0f1
commit
9954d914c7
|
@ -64,6 +64,7 @@ class CouchRest
|
||||||
private
|
private
|
||||||
def encode_attachments attachments
|
def encode_attachments attachments
|
||||||
attachments.each do |k,v|
|
attachments.each do |k,v|
|
||||||
|
next if v['stub']
|
||||||
v['data'] = base64(v['data'])
|
v['data'] = base64(v['data'])
|
||||||
end
|
end
|
||||||
attachments
|
attachments
|
||||||
|
|
|
@ -208,6 +208,30 @@ describe CouchRest::Database do
|
||||||
end
|
end
|
||||||
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
|
describe "PUT document with multiple attachments" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@attach = "<html><head><title>My Doc</title></head><body><p>Has words.</p></body></html>"
|
@attach = "<html><head><title>My Doc</title></head><body><p>Has words.</p></body></html>"
|
||||||
|
|
Loading…
Reference in a new issue