Sha256: 820fa1550290b54a79fc0f76581ef7102352b72d7a8c382fc368840297a65403

Contents?: true

Size: 1.37 KB

Versions: 10

Compression:

Stored size: 1.37 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'rid/document'

describe "Attachments" do
  before do
    @doc = Rid::Document.new
  end

  describe "map" do
    describe "_attachments encoding and content_type" do
      it "should proper encode and add plain text content type" do
        @doc.hash = { "_attachments" => { "key" => "value" } }
        @doc.map_attachments!
        @doc.hash.should == { "_attachments" => { "key" => { "data" => "dmFsdWU=", "content_type" => "text/plain" } } }
      end

      it "should proper encode and add html content type" do
        @doc.hash = { "_attachments" => { "key.html" => "value" } }
        @doc.map_attachments!
        @doc.hash.should == { "_attachments" => { "key.html" => { "data" => "dmFsdWU=", "content_type" => "text/html" } } }
      end

      it "should proper map nested attachments" do
        @doc.hash = { "_attachments" => { "hash" => { "key" => "value" } } }
        @doc.map_attachments!
        @doc.hash.should == { "_attachments" => { "hash/key" => { "data" => "dmFsdWU=", "content_type" => "text/plain" } } }
      end
    end
  end

  describe "reduce" do
    it "should decode _attachments data" do
      @doc.hash = { "_attachments" => { "key" => { "data" => "dmFsdWU=" } } }
      @doc.reduce_attachments!
      @doc.hash.should == { "_attachments" => { "key" => "value" } }
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
rid-core-1.5.2 spec/rid/attachments_spec.rb
rid-core-1.5.1 spec/rid/attachments_spec.rb
rid-core-1.5.0 spec/rid/attachments_spec.rb
rid-core-1.4.0 spec/rid/attachments_spec.rb
rid-core-1.3.0 spec/rid/attachments_spec.rb
rid-core-1.2.0 spec/rid/attachments_spec.rb
rid-core-1.1.0 spec/rid/attachments_spec.rb
rid-core-1.0.3 spec/rid/attachments_spec.rb
rid-1.0.3 spec/rid/attachments_spec.rb
rid-1.0.2 spec/rid/attachments_spec.rb