Sha256: e04ca61a7450aa280781aafdc954f68e9564dfca9849fb2adf04fec5a0e8ee17

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

require 'test_helper'
require_relative '../../../../app/models/concerns/simple_form_attachments/attachment'

describe Attachment do
  let(:temporary_attachment) { Attachment.new(temporary: true) }
  let(:permanent_attachment) { Attachment.new }

  before do
    temporary_attachment.save
    permanent_attachment.save
  end

  describe 'scopes' do
    describe ':temporary' do
      it 'has :temporary scope' do
        Attachment.must_respond_to :temporary
      end

      it 'returns the temporary attachments' do
        Attachment.temporary.to_a.must_include temporary_attachment
      end

      it 'does not return the temporary attachments for' do
        Attachment.temporary.to_a.wont_include permanent_attachment
      end
    end

    describe ':permanent' do
      it 'has :permanent scope' do
        Attachment.must_respond_to :permanent
      end

      it 'returns the permanent attachments' do
        Attachment.permanent.to_a.must_include permanent_attachment
      end

      it 'does not return the temporary attachments for' do
        Attachment.permanent.to_a.wont_include temporary_attachment
      end
    end
  end

  describe '#temporary' do
    it 'it should have field :temporary' do
      temporary_attachment.must_respond_to :temporary
    end

    it 'should default to true' do
      temporary_attachment.temporary.must_equal true
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
simple_form_attachments-0.2.3 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.2.2 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.2.1 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.2.0 test/models/concerns/simple_form_attachments/attachment_test.rb