Sha256: c2c803648becfbc91c6cf440e3998108a34457a26858b0fbc600e9dc88b0e5cc

Contents?: true

Size: 1.04 KB

Versions: 18

Compression:

Stored size: 1.04 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
        is_expected.to match(/\/attachment\/#{attachment.id}\/download\/#{attachment.file_name}/)
      end

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

        it { is_expected.to be_nil }
      end
    end

    describe '#preview_text' do

      it "returns the attachment's name as preview text" do
        expect(essence.preview_text).to eq(attachment.name)
      end

      context "with no attachment assigned" do
        it "returns empty string" do
          essence.attachment = nil
          expect(essence.preview_text).to eq('')
        end
      end
    end

  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
alchemy_cms-3.2.1 spec/models/essence_file_spec.rb
alchemy_cms-3.1.3 spec/models/essence_file_spec.rb
lc_alchemy_cms-3.2.1 spec/models/essence_file_spec.rb
lc_alchemy_cms-3.2.0 spec/models/essence_file_spec.rb
alchemy_cms-3.2.0 spec/models/essence_file_spec.rb
alchemy_cms-3.2.0.rc1 spec/models/essence_file_spec.rb
alchemy_cms-3.2.0.beta spec/models/essence_file_spec.rb
alchemy_cms-3.1.1 spec/models/essence_file_spec.rb
alchemy_cms-3.1.0 spec/models/essence_file_spec.rb
alchemy_cms-3.1.0.rc3 spec/models/essence_file_spec.rb
alchemy_cms-3.1.0.rc2 spec/models/essence_file_spec.rb
alchemy_cms-3.1.0.rc1 spec/models/essence_file_spec.rb
alchemy_cms-3.1.0.beta6 spec/models/essence_file_spec.rb
alchemy_cms-3.1.0.beta5 spec/models/essence_file_spec.rb
alchemy_cms-3.1.0.beta4 spec/models/essence_file_spec.rb
alchemy_cms-3.1.0.beta3 spec/models/essence_file_spec.rb
alchemy_cms-3.1.0.beta2 spec/models/essence_file_spec.rb
alchemy_cms-3.1.0.beta1 spec/models/essence_file_spec.rb