Sha256: 0fcbe6d379e356e3c59405647ae71c42c74a9eece5b55ac17b25ded545b85a85

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

require 'rails_helper'

describe MessageTrain::AttachmentsHelper do
  include_context 'loaded site'

  before do
    view.extend BootstrapLeather::ApplicationHelper
  end

  describe '#attachment_icon' do
    context 'when attachment is an image' do
      subject { helper.attachment_icon(image_attachment) }
      it do
        should have_tag(
          :img,
          with: { src: image_attachment.attachment.url(:thumb) }
        )
      end
    end
    context 'when attachment is a file' do
      subject { helper.attachment_icon(pdf_attachment) }
      it { should have_tag :span, with: { class: 'glyphicon-save-file' } }
    end
  end

  describe '#attachment_link' do
    context 'when attachment is an image' do
      subject { helper.attachment_link(image_attachment) }
      it do
        should have_tag(
          :a,
          with: {
            href: '#',
            class: 'thumbnail',
            'data-toggle' => 'modal',
            'data-target' => '#attachment_preview',
            'data-src' => image_attachment.attachment.url(:large),
            'data-original' => image_attachment.attachment.url(:original),
            'data-text' => 'Click for Original'
          }
        )
      end
    end
    context 'when attachment is a file' do
      subject { helper.attachment_link(pdf_attachment) }
      it do
        should have_tag(
          :a,
          with: { href: pdf_attachment.attachment.url, class: 'thumbnail' }
        )
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
message_train-0.7.6 spec/helpers/message_train/attachment_helper_spec.rb
message_train-0.7.5 spec/helpers/message_train/attachment_helper_spec.rb
message_train-0.7.3 spec/helpers/message_train/attachment_helper_spec.rb
message_train-0.7.2 spec/helpers/message_train/attachment_helper_spec.rb