Sha256: aedd26eebac07027c257f01c1b901b4637ae3d0c65b0d3a78c49d9bf079eb347

Contents?: true

Size: 957 Bytes

Versions: 37

Compression:

Stored size: 957 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
    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

37 entries across 37 versions & 3 rubygems

Version Path
couch_potato-1.4.0 spec/attachments_spec.rb
couch_potato-1.3.0 spec/attachments_spec.rb
couch_potato-1.2.0 spec/attachments_spec.rb
couch_potato-1.1.4 spec/attachments_spec.rb
couch_potato-1.1.2 spec/attachments_spec.rb
couch_potato-1.1.1 spec/attachments_spec.rb
couch_potato-1.1.0 spec/attachments_spec.rb
couch_potato-1.0.1 spec/attachments_spec.rb
couch_potato-1.0.0 spec/attachments_spec.rb
couch_potato-0.7.1 spec/attachments_spec.rb
couch_potato-0.7.0 spec/attachments_spec.rb
couch_potato-0.7.0.pre.1 spec/attachments_spec.rb
couch_potato-0.6.0 spec/attachments_spec.rb
couch_potato-0.5.7 spec/attachments_spec.rb
couch_potato-rails2-0.5.10 spec/attachments_spec.rb
couch_potato-rails2-0.5.9 spec/attachments_spec.rb
couch_potato-rails2-0.5.8 spec/attachments_spec.rb
couch_potato-rails2-0.5.7 spec/attachments_spec.rb
couch_potato-rails2-0.5.6 spec/attachments_spec.rb
couch_potato-0.5.6 spec/attachments_spec.rb