Sha256: a730fadaf6145abdb36e35e3438530b64270affe0c74e5002f99692747d03e69

Contents?: true

Size: 1.76 KB

Versions: 4

Compression:

Stored size: 1.76 KB

Contents

require 'rails_helper'

module Mks
  module Edm
    RSpec.describe EquipmentValuation, type: :model do
      it 'has a valid factory' do
        expect(create(:equipment_valuation)).to be_valid
      end

      it 'is invalid without an equipment item' do
        expect(build(:equipment_valuation, equipment_item: nil)).not_to be_valid
      end

      it 'is invalid without an initial_cost' do
        expect(build(:equipment_valuation, initial_cost: nil)).not_to be_valid
      end

      it 'is invalid without a residual value' do
        expect(build(:equipment_valuation, residual_value: nil)).not_to be_valid
      end

      it 'is invalid without working hours per year' do
        expect(build(:equipment_valuation, work_hrs_per_yr: nil)).not_to be_valid
      end

      it 'is invalid without life year' do
        expect(build(:equipment_valuation, life_year: nil)).not_to be_valid
      end

      it 'is invalid without insurance premium' do
        expect(build(:equipment_valuation, insurance_premium: nil)).not_to be_valid
      end

      it 'is invalid without fuel cost per hour' do
        expect(build(:equipment_valuation, fuel_cost_per_hr: nil)).not_to be_valid
      end

      it 'gives makes a new valuation current by default' do
        valuation = create(:equipment_valuation, is_current: nil)
        expect(valuation.is_current).to be_truthy
      end

      it 'resets other valuations before making the new valuation current' do
        ei = create(:equipment_item)
        v1 = create(:equipment_valuation, equipment_item: ei)
        expect(v1.is_current).to be_truthy
        v2 = create(:equipment_valuation, equipment_item: ei)
        expect(v2.is_current).to be_truthy
        v1.reload
        expect(v1.is_current).to be_falsey
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mks_edm-1.0.5 spec/models/mks/edm/equipment_valuation_spec.rb
mks_edm-1.0.4 spec/models/mks/edm/equipment_valuation_spec.rb
mks_edm-1.0.2 spec/models/mks/edm/equipment_valuation_spec.rb
mks_edm-1.0.1 spec/models/mks/edm/equipment_valuation_spec.rb