Sha256: 40194a32c314157a156f431d12e989a7c836dc2fd08768719c6829dbb98dbde6

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

module NewspaperWorks
  RSpec.describe DerivativeAttachment, type: :model do
    it "requires some columns to be considered complete" do
      model = described_class.create
      # attempt save without required data; expect failure
      expect { model.save! }.to raise_exception(ActiveRecord::RecordInvalid)
    end

    it "saves when constructed with all field values" do
      model = described_class.create(
        fileset_id: 'a1b2c3d4e5',
        path: '/path/to/somefile',
        destination_name: 'txt'
      )
      # attempt save without required data; expect failure
      expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
    end

    it "saves when all fields completely set" do
      model = described_class.create
      model.fileset_id = 'someid123'
      model.path = '/path/to/somefile'
      model.destination_name = 'txt'
      expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
    end

    it "saves when only path, destination_name set" do
      model = described_class.create
      model.fileset_id = nil
      model.path = '/path/to/somefile'
      model.destination_name = 'txt'
      expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
newspaper_works-1.0.1 spec/models/newspaper_works/derivative_attachment_spec.rb
newspaper_works-1.0.0 spec/models/newspaper_works/derivative_attachment_spec.rb
newspaper_works-0.1.0 spec/models/newspaper_works/derivative_attachment_spec.rb