Sha256: be6b7588dc07fb02dffa14ad8ffcc363439784533195fabcfdad53b3d7bcb7a1

Contents?: true

Size: 760 Bytes

Versions: 3

Compression:

Stored size: 760 Bytes

Contents

require 'rails_helper'

RSpec.describe Attachy::Viewer, '.attachments' do
  let!(:object) { create :user }

  before { allow(Cloudinary::Uploader).to receive(:remove_tag) }

  subject { described_class.new method, object }

  context 'with one file' do
    let!(:method) { :avatar }
    let!(:file)   { create :file, attachable: object, scope: method }

    it 'returns an array' do
      expect(subject.attachments).to eq [file]
    end
  end

  context 'with more than one files' do
    let!(:method) { :photos }
    let!(:file_1) { create :file, attachable: object, scope: method }
    let!(:file_2) { create :file, attachable: object, scope: method }

    it 'returns an array' do
      expect(subject.attachments).to eq [file_1, file_2]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
attachy-0.1.2 spec/models/attachy/viewer/attachments_spec.rb
attachy-0.1.1 spec/models/attachy/viewer/attachments_spec.rb
attachy-0.1.0 spec/models/attachy/viewer/attachments_spec.rb