Sha256: 467de5aa3c5ee363dab1d9597cc1822d6d419e31cc0319129eb50718f7c3c88e

Contents?: true

Size: 971 Bytes

Versions: 17

Compression:

Stored size: 971 Bytes

Contents

require 'spec_helper'

describe CouchPotato, 'attachments' do
  it "should persist an attachment" do
    comment = Comment.new :title => 'nil'
    comment._attachments['body'] = {'data' => 'a useful comment', 'content_type' => 'text/plain'}
    CouchPotato.database.save! comment
    expect(CouchPotato.couchrest_database.fetch_attachment(comment.to_hash, 'body').to_s).to eq('a useful comment')
  end
  
  it "should give me information about the attachments of a document" do
    comment = Comment.new :title => 'nil'
    comment._attachments = {'body' => {'data' => 'a useful comment', 'content_type' => 'text/plain'}}
    CouchPotato.database.save! comment
    comment_reloaded = CouchPotato.database.load comment.id
    expect(comment_reloaded._attachments["body"]).to include({"content_type" => "text/plain", "stub" => true, "length" => 16})
  end
  
  it "should have an empty array for a new object" do
    expect(Comment.new._attachments).to eq({})
  end
  
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
couch_potato-1.18.0 spec/attachments_spec.rb
couch_potato-1.17.0 spec/attachments_spec.rb
couch_potato-1.16.0 spec/attachments_spec.rb
couch_potato-1.15.0 spec/attachments_spec.rb
couch_potato-1.14.0 spec/attachments_spec.rb
couch_potato-1.13.0 spec/attachments_spec.rb
couch_potato-1.12.1 spec/attachments_spec.rb
couch_potato-1.12.0 spec/attachments_spec.rb
couch_potato-1.11.0 spec/attachments_spec.rb
couch_potato-1.10.1 spec/attachments_spec.rb
couch_potato-1.10.0 spec/attachments_spec.rb
couch_potato-1.9.0 spec/attachments_spec.rb
couch_potato-1.7.1 spec/attachments_spec.rb
couch_potato-1.7.0 spec/attachments_spec.rb
couch_potato-1.6.5 spec/attachments_spec.rb
couch_potato-1.6.4 spec/attachments_spec.rb
couch_potato-1.6.3 spec/attachments_spec.rb