Sha256: 33c86fd196d0ee6cb34c716c5e56b534eca5ffe3a8c8a586922e4fe3e65f13a5

Contents?: true

Size: 1.35 KB

Versions: 14

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 }
  let(:permanent_attachment) { Attachment.new(temporary: false) }

  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

14 entries across 14 versions & 1 rubygems

Version Path
simple_form_attachments-0.1.5 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.1.4 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.1.3 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.1.2 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.1.1 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.1.0 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.0.9 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.0.8 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.0.7 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.0.6 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.0.5 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.0.4 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.0.3 test/models/concerns/simple_form_attachments/attachment_test.rb
simple_form_attachments-0.0.1 test/models/concerns/simple_form_attachments/attachment_test.rb