Sha256: 6ae5e11c34be072123569b1fde69756858c484f67d5b586b1bbc6b481ec89047

Contents?: true

Size: 791 Bytes

Versions: 3

Compression:

Stored size: 791 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Attachy::Viewer, '.attachments' do
  subject { described_class.new method, object }

  let!(:object) { create :user }

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

  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.4.0 spec/models/attachy/viewer/attachments_spec.rb
attachy-0.3.0 spec/models/attachy/viewer/attachments_spec.rb
attachy-0.2.0 spec/models/attachy/viewer/attachments_spec.rb