Sha256: e7b0870fec45963b5f7287e679e7f44b5853f6386465c73e2375aefa060631b7

Contents?: true

Size: 1.36 KB

Versions: 9

Compression:

Stored size: 1.36 KB

Contents

require 'rails_helper'

module Logistics
  module Core
    RSpec.describe ServiceDeliveryUnit, type: :model do
      it 'has a valid factory' do
        expect(create(:service_delivery_unit)).to be_valid
      end

      it 'is invalid with no code' do
        expect(build(:service_delivery_unit, code: nil)).not_to be_valid
      end

      it 'is invalid with no name' do
        expect(build(:service_delivery_unit, name: nil)).not_to be_valid
      end

      it 'is invalid with duplicate code' do
        sdu = create(:service_delivery_unit)
        expect(build(:service_delivery_unit, code: sdu.code)).not_to be_valid
      end

      it 'is invalid with duplicate name' do
        sdu = create(:service_delivery_unit)
        expect(build(:service_delivery_unit, name: sdu.name)).not_to be_valid
      end

      it 'is invalid with no currency' do
        expect(build(:service_delivery_unit, currency: nil)).not_to be_valid
      end

      it 'is invalid with no service delivery unit type' do
        expect(build(:service_delivery_unit, service_delivery_unit_type: nil)).not_to be_valid
      end

      it 'can access chargeable services' do
        sdu = create(:service_delivery_unit)
        sdu.chargeable_services = [create(:chargeable_service), create(:chargeable_service)]
        sdu.reload
        expect(sdu.chargeable_services.count).to eq 2
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logistics_core-21.11.2 spec/models/logistics/core/service_delivery_unit_spec.rb
logistics_core-21.11.1 spec/models/logistics/core/service_delivery_unit_spec.rb
logistics_core-21.08.1 spec/models/logistics/core/service_delivery_unit_spec.rb
logistics_core-21.03.1 spec/models/logistics/core/service_delivery_unit_spec.rb
logistics_core-20.10.3 spec/models/logistics/core/service_delivery_unit_spec.rb
logistics_core-20.10.2 spec/models/logistics/core/service_delivery_unit_spec.rb
logistics_core-20.10.1 spec/models/logistics/core/service_delivery_unit_spec.rb
logistics_core-20.9.1 spec/models/logistics/core/service_delivery_unit_spec.rb
logistics_core-20.8.1 spec/models/logistics/core/service_delivery_unit_spec.rb