From 8f1b3f39e002a68d4d8d736d4541c7f6dd7477ed Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:35:02 +0000 Subject: [PATCH] CLDC-3000 Display available from date in the error message (#2058) * Display available from date in the error message * update created at in tests --- app/models/validations/setup_validations.rb | 2 +- spec/models/validations/setup_validations_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/validations/setup_validations.rb b/app/models/validations/setup_validations.rb index 3fd760c30..5ea921e4f 100644 --- a/app/models/validations/setup_validations.rb +++ b/app/models/validations/setup_validations.rb @@ -150,7 +150,7 @@ private elsif absorbing_owning_organisation_inactive?(record) record.errors.add :startdate, I18n.t("validations.setup.startdate.invalid_absorbing_organisations_start_date.same_organisation", owning_organisation: record.owning_organisation.name, - owning_organisation_available_from: record.owning_organisation.created_at.to_formatted_s(:govuk_date)) + owning_organisation_available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) end end diff --git a/spec/models/validations/setup_validations_spec.rb b/spec/models/validations/setup_validations_spec.rb index a226ee79d..a7a038cc4 100644 --- a/spec/models/validations/setup_validations_spec.rb +++ b/spec/models/validations/setup_validations_spec.rb @@ -136,8 +136,8 @@ RSpec.describe Validations::SetupValidations do Timecop.return end - let(:absorbing_organisation) { create(:organisation, created_at: Time.zone.local(2023, 2, 1, 4, 5, 6), available_from: Time.zone.local(2023, 2, 1, 4, 5, 6), name: "Absorbing org") } - let(:absorbing_organisation_2) { create(:organisation, created_at: Time.zone.local(2023, 2, 1), available_from: Time.zone.local(2023, 2, 1), name: "Absorbing org 2") } + let(:absorbing_organisation) { create(:organisation, created_at: Time.zone.local(2023, 1, 30, 4, 5, 6), available_from: Time.zone.local(2023, 2, 1, 4, 5, 6), name: "Absorbing org") } + let(:absorbing_organisation_2) { create(:organisation, created_at: Time.zone.local(2023, 1, 30), available_from: Time.zone.local(2023, 2, 1), name: "Absorbing org 2") } let(:merged_organisation) { create(:organisation, name: "Merged org") } let(:merged_organisation_2) { create(:organisation, name: "Merged org 2") }