Sha256: 6c8f67d08ce4555b4cbdae2bc889b9bf3de50603b630a9be4f7366720965e36f

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

module Alchemy
  describe EssenceFile do

    let(:attachment) { build_stubbed(:attachment) }
    let(:essence)    { EssenceFile.new(attachment: attachment) }

    it_behaves_like "an essence" do
      let(:essence)          { EssenceFile.new }
      let(:ingredient_value) { attachment }
    end

    describe '#attachment_url' do
      subject { essence.attachment_url }

      it "returns the download attachment url." do
        should match(/\/attachment\/#{attachment.id}\/download\/#{attachment.file_name}/)
      end

      context 'without attachment assigned' do
        let(:attachment) { nil }

        it { should be_nil }
      end
    end

    describe '#preview_text' do

      it "returns the attachment's name as preview text" do
        essence.preview_text.should == attachment.name
      end

      context "with no attachment assigned" do
        it "returns empty string" do
          essence.attachment = nil
          essence.preview_text.should == ''
        end
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
alchemy_cms-3.0.4 spec/models/essence_file_spec.rb
alchemy_cms-3.0.3 spec/models/essence_file_spec.rb
alchemy_cms-3.0.2 spec/models/essence_file_spec.rb
alchemy_cms-3.0.1 spec/models/essence_file_spec.rb
alchemy_cms-3.0.0 spec/models/essence_file_spec.rb
alchemy_cms-3.0.0.rc8 spec/models/essence_file_spec.rb
alchemy_cms-3.0.0.rc7 spec/models/essence_file_spec.rb
alchemy_cms-3.0.0.rc6 spec/models/essence_file_spec.rb
alchemy_cms-3.0.0.rc5 spec/models/essence_file_spec.rb