Sha256: 267a8816f7ca382099f4b684a2e0896fec0fc58d944a1ad72bc56730cf2921d6
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe Attachy::Viewer, '.attachments' do let!(:object) { create :user } before { allow(Cloudinary::Uploader).to receive(:remove_tag) } context 'with no files' do subject { described_class.new :avatar, object } specify { expect(subject.attachments).to eq [] } end context 'when is has one' do subject { described_class.new method, object } let!(:method) { :avatar } context 'and has no files' do specify { expect(subject.attachments).to eq [] } end context 'and has file' do let!(:file) { create :file, attachable: object, scope: method } it 'returns an array with this file' do expect(subject.attachments).to eq [file] end end end context 'when is has many' do subject { described_class.new method, object } let!(:method) { :photos } context 'and has no files' do specify { expect(subject.attachments).to eq [] } end context 'and has files' do let!(:file_1) { create :file, attachable: object, scope: method } let!(:file_2) { create :file, attachable: object, scope: method } it 'returns an array with this files' do expect(subject.attachments).to eq [file_1, file_2] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
attachy-0.4.1 | spec/models/attachy/viewer/attachments_spec.rb |