Sha256: f9a776cb9502135becd9363bf7d4222b315c068b914b7618df9f0ae3f14f7356

Contents?: true

Size: 1.38 KB

Versions: 6

Compression:

Stored size: 1.38 KB

Contents

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

describe "Attachments" do
  before do
    @doc = Rid::DesignDocument.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

6 entries across 6 versions & 1 rubygems

Version Path
rid-0.5.2 spec/rid/attachments_spec.rb
rid-0.5.1 spec/rid/attachments_spec.rb
rid-0.5.0 spec/rid/attachments_spec.rb
rid-0.4.1 spec/rid/attachments_spec.rb
rid-0.4.0 spec/rid/attachments_spec.rb
rid-0.3.1 spec/rid/attachments_spec.rb