require 'rails_helper' module Logistics module Core RSpec.describe CustomsTransportTariff, type: :model do it 'has a valid factory' do expect(create(:customs_transport_tariff)).to be_valid end it 'is invalid with no route' do expect(build(:customs_transport_tariff, :route => nil)).not_to be_valid end it 'is invalid with no entry point' do expect(build(:customs_transport_tariff, :entry_point => nil)).not_to be_valid end it 'is invalid with no total distance' do expect(build(:customs_transport_tariff, :total_distance => nil)).not_to be_valid end it 'is invalid with no distance to entry point' do expect(build(:customs_transport_tariff, :distance_to_entry_point => nil)).not_to be_valid end it 'is invalid with no proportion' do expect(build(:customs_transport_tariff, :proportion => nil)).not_to be_valid end it 'is invalid with duplicate route and entry point' do ctt = create(:customs_transport_tariff) expect(build(:customs_transport_tariff, :route => ctt.route, :entry_point => ctt.entry_point)).not_to be_valid end end end end