require 'rails_helper' module Mks module Rate RSpec.describe RateChangeRequest, type: :model do it 'has valid factory' do expect(create(:rate_change_request)).to be_valid end it 'is invalid without authorization date' do expect(build(:rate_change_request, authorized_on: nil)).not_to be_valid end it 'is invalid without reference number' do expect(build(:rate_change_request, reference_number: nil)).not_to be_valid end it 'is invalid with duplicate reference number' do rcr = create(:rate_change_request) expect(build(:rate_change_request, reference_number: rcr.reference_number)).not_to be_valid end it 'is invalid without authorized by' do expect(build(:rate_change_request, authorized_by: nil)).not_to be_valid end it 'is invalid without effective date' do expect(build(:rate_change_request, effective_on: nil)).not_to be_valid end it 'is invalid without rate' do expect(build(:rate_change_request, rates: {})).not_to be_valid end it 'is invalid without status' do expect(build(:rate_change_request, status: nil)).not_to be_valid end it 'is valid without approved by' do expect(create(:rate_change_request, approved_by: nil)).to be_valid end end end end