Sha256: 2b967c487f6f7c15ad6cf14bfae1e3e14214da844270e11fa109cb317c188a2d

Contents?: true

Size: 859 Bytes

Versions: 9

Compression:

Stored size: 859 Bytes

Contents

require 'rails_helper'

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

      it 'is invalid with no abbreviation' do
        expect(build(:unit, :abbreviation => '')).not_to be_valid
      end

      it 'is invalid with no name' do
        expect(build(:unit, :name => '')).not_to be_valid
      end

      it 'is invalid with duplicate abbreviation' do
        u = create(:unit)
        expect(build(:unit, :abbreviation => u.abbreviation)).not_to be_valid
      end

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

      it 'is invalid with no unit type' do
        expect(build(:unit, :unit_type => nil)).not_to be_valid
      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/unit_spec.rb
logistics_core-21.11.1 spec/models/logistics/core/unit_spec.rb
logistics_core-21.08.1 spec/models/logistics/core/unit_spec.rb
logistics_core-21.03.1 spec/models/logistics/core/unit_spec.rb
logistics_core-20.10.3 spec/models/logistics/core/unit_spec.rb
logistics_core-20.10.2 spec/models/logistics/core/unit_spec.rb
logistics_core-20.10.1 spec/models/logistics/core/unit_spec.rb
logistics_core-20.9.1 spec/models/logistics/core/unit_spec.rb
logistics_core-20.8.1 spec/models/logistics/core/unit_spec.rb