Sha256: c79e0bd46c83d98975b90c0c8b784d167222cb6be08c30ed1f02e9fa627b2c2d

Contents?: true

Size: 792 Bytes

Versions: 1

Compression:

Stored size: 792 Bytes

Contents

require 'spec_helper'

describe Mavenlink::Attachment, stub_requests: true do
  it_should_behave_like 'model', 'attachments'

  describe 'validations' do
    it { should validate_presence_of :data }
    it { should validate_presence_of :type }
    it { should ensure_inclusion_of(:type).in_array(%w[receipt post_attachment]) }
    it { should_not allow_value(nil).for(:type) }
  end

  describe '#save' do
    context 'persisted record' do
      subject { described_class.new(id: 1, data: 'some data', type: 'receipt') }

      it { should be_persisted }

      specify do
        expect { subject.save }.to raise_error Mavenlink::RecordLockedError
      end
    end

    context 'new record' do
      specify do
        expect { subject.save }.not_to raise_error
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mavenlink-0.0.1 spec/lib/mavenlink/attachment_spec.rb