Sha256: 753f27abfa11c232ea19457a7c3fee6db327272c8bad82ee6c3782c025fef5af

Contents?: true

Size: 880 Bytes

Versions: 3

Compression:

Stored size: 880 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.should == {"body" => {"content_type" => "text/plain", "stub" => true, "length" => 16}}
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
langalex-couch_potato-0.2.11 spec/attachments_spec.rb
langalex-couch_potato-0.2.12 spec/attachments_spec.rb
langalex-couch_potato-0.2.9 spec/attachments_spec.rb