Sha256: 389b017d825540b226d9c9cc36e77bfbf4571731bdf69f33a15c595443852a62

Contents?: true

Size: 983 Bytes

Versions: 13

Compression:

Stored size: 983 Bytes

Contents

require File.dirname(__FILE__) + '/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
    CouchPotato.couchrest_database.fetch_attachment(comment.to_hash, 'body').to_s.should == '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
    comment_reloaded._attachments["body"].should include({"content_type" => "text/plain", "stub" => true, "length" => 16})
  end
  
  it "should have an empty array for a new object" do
    Comment.new._attachments.should == {}
  end
  
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
couch_potato-0.2.27 spec/attachments_spec.rb
couch_potato-0.2.26 spec/attachments_spec.rb
couch_potato-0.2.25 spec/attachments_spec.rb
couch_potato-0.2.24 spec/attachments_spec.rb
couch_potato-0.2.23 spec/attachments_spec.rb
couch_potato-0.2.22 spec/attachments_spec.rb
couch_potato-0.2.21 spec/attachments_spec.rb
couch_potato-0.2.20 spec/attachments_spec.rb
couch_potato-0.2.19 spec/attachments_spec.rb
couch_potato-0.2.18 spec/attachments_spec.rb
couch_potato-0.2.17 spec/attachments_spec.rb
couch_potato-0.2.16 spec/attachments_spec.rb
couch_potato-0.2.15 spec/attachments_spec.rb