From e51e76a0f7c08361fab2532dfe74a9809dc227b8 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 11 Apr 2023 11:30:42 +0100 Subject: [PATCH] Rename soft validation methods --- .../sales/pages/buyer_live_in_value_check.rb | 4 +-- .../validations/sales/soft_validations.rb | 4 +-- config/locales/en.yml | 4 +-- .../pages/buyer_live_in_value_check_spec.rb | 8 ++--- .../sales/soft_validations_spec.rb | 34 +++++++++---------- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/app/models/form/sales/pages/buyer_live_in_value_check.rb b/app/models/form/sales/pages/buyer_live_in_value_check.rb index 7d5a2e48f..067ba96ca 100644 --- a/app/models/form/sales/pages/buyer_live_in_value_check.rb +++ b/app/models/form/sales/pages/buyer_live_in_value_check.rb @@ -3,11 +3,11 @@ class Form::Sales::Pages::BuyerLiveInValueCheck < Form::Sales::Pages::Person super @depends_on = [ { - "buyer#{person_index}_not_livein?" => true, + "buyer#{person_index}_livein_wrong_for_ownership_type?" => true, }, ] @title_text = { - "translation" => "soft_validations.buyer#{person_index}_not_livein.title_text", + "translation" => "soft_validations.buyer#{person_index}_livein_wrong_for_ownership_type.title_text", "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }], } @informative_text = {} diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index 928566cc1..354bc7fd7 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -123,13 +123,13 @@ module Validations::Sales::SoftValidations mortgage_deposit_and_grant_total != value_with_discount && discounted_ownership_sale? end - def buyer1_not_livein? + def buyer1_livein_wrong_for_ownership_type? return unless ownershipsch && buy1livein (discounted_ownership_sale? || shared_ownership_scheme?) && buy1livein == 2 end - def buyer2_not_livein? + def buyer2_livein_wrong_for_ownership_type? return unless ownershipsch && buy2livein return unless joint_purchase? diff --git a/config/locales/en.yml b/config/locales/en.yml index 5e3b2253f..cf11c6774 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -551,9 +551,9 @@ en: informative_text: "Your given mortgage, deposit and grant total is £%{mortgage_deposit_and_grant_total}" care_home_charges: title_text: "Care home charges should be provided if this is a care home accommodation" - buyer1_not_livein: + buyer1_livein_wrong_for_ownership_type: title_text: "You told us that buyer 1 will not live in the property. For %{ownership_scheme} types, the buyer usually lives in the property." - buyer2_not_livein: + buyer2_livein_wrong_for_ownership_type: title_text: "You told us that buyer 2 will not live in the property. For %{ownership_scheme} types, the buyer usually lives in the property." devise: diff --git a/spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb b/spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb index d92186c89..9d00b086b 100644 --- a/spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb +++ b/spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb @@ -27,7 +27,7 @@ RSpec.describe Form::Sales::Pages::BuyerLiveInValueCheck, type: :model do it "has correct depends_on" do expect(page.depends_on).to eq([ { - "buyer1_not_livein?" => true, + "buyer1_livein_wrong_for_ownership_type?" => true, }, ]) end @@ -38,7 +38,7 @@ RSpec.describe Form::Sales::Pages::BuyerLiveInValueCheck, type: :model do it "has the correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.buyer1_not_livein.title_text", + "translation" => "soft_validations.buyer1_livein_wrong_for_ownership_type.title_text", "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }], }) end @@ -49,14 +49,14 @@ RSpec.describe Form::Sales::Pages::BuyerLiveInValueCheck, type: :model do it "has correct depends_on" do expect(page.depends_on).to eq([ { - "buyer2_not_livein?" => true, + "buyer2_livein_wrong_for_ownership_type?" => true, }, ]) end it "has the correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.buyer2_not_livein.title_text", + "translation" => "soft_validations.buyer2_livein_wrong_for_ownership_type.title_text", "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }], }) end diff --git a/spec/models/validations/sales/soft_validations_spec.rb b/spec/models/validations/sales/soft_validations_spec.rb index 4298dc781..ae20e1111 100644 --- a/spec/models/validations/sales/soft_validations_spec.rb +++ b/spec/models/validations/sales/soft_validations_spec.rb @@ -914,7 +914,7 @@ RSpec.describe Validations::Sales::SoftValidations do end end - describe "#buyer1_not_livein?" do + describe "#buyer1_livein_wrong_for_ownership_type?" do context "when it's a shared ownership" do let(:record) { FactoryBot.build(:sales_log, ownershipsch: 1) } @@ -924,7 +924,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns true" do - expect(record).to be_buyer1_not_livein + expect(record).to be_buyer1_livein_wrong_for_ownership_type end end @@ -934,7 +934,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns false" do - expect(record).not_to be_buyer1_not_livein + expect(record).not_to be_buyer1_livein_wrong_for_ownership_type end end end @@ -948,7 +948,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns true" do - expect(record).to be_buyer1_not_livein + expect(record).to be_buyer1_livein_wrong_for_ownership_type end end @@ -958,7 +958,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns false" do - expect(record).not_to be_buyer1_not_livein + expect(record).not_to be_buyer1_livein_wrong_for_ownership_type end end end @@ -972,7 +972,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns false" do - expect(record).not_to be_buyer1_not_livein + expect(record).not_to be_buyer1_livein_wrong_for_ownership_type end end @@ -982,7 +982,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns false" do - expect(record).not_to be_buyer1_not_livein + expect(record).not_to be_buyer1_livein_wrong_for_ownership_type end end end @@ -995,12 +995,12 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns false" do - expect(record).not_to be_buyer1_not_livein + expect(record).not_to be_buyer1_livein_wrong_for_ownership_type end end end - describe "#buyer2_not_livein?" do + describe "#buyer2_livein_wrong_for_ownership_type?" do context "when it's a shared ownership" do let(:record) { FactoryBot.build(:sales_log, ownershipsch: 1, jointpur: 1) } @@ -1010,7 +1010,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns true" do - expect(record).to be_buyer2_not_livein + expect(record).to be_buyer2_livein_wrong_for_ownership_type end end @@ -1020,7 +1020,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns false" do - expect(record).not_to be_buyer2_not_livein + expect(record).not_to be_buyer2_livein_wrong_for_ownership_type end end @@ -1031,7 +1031,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns false" do - expect(record).not_to be_buyer2_not_livein + expect(record).not_to be_buyer2_livein_wrong_for_ownership_type end end end @@ -1045,7 +1045,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns true" do - expect(record).to be_buyer2_not_livein + expect(record).to be_buyer2_livein_wrong_for_ownership_type end end @@ -1055,7 +1055,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns false" do - expect(record).not_to be_buyer2_not_livein + expect(record).not_to be_buyer2_livein_wrong_for_ownership_type end end end @@ -1069,7 +1069,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns false" do - expect(record).not_to be_buyer2_not_livein + expect(record).not_to be_buyer2_livein_wrong_for_ownership_type end end @@ -1079,7 +1079,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns false" do - expect(record).not_to be_buyer2_not_livein + expect(record).not_to be_buyer2_livein_wrong_for_ownership_type end end end @@ -1092,7 +1092,7 @@ RSpec.describe Validations::Sales::SoftValidations do end it "returns false" do - expect(record).not_to be_buyer2_not_livein + expect(record).not_to be_buyer2_livein_wrong_for_ownership_type end end end