Browse Source

Rename soft validation methods

pull/1521/head
Kat 3 years ago
parent
commit
e51e76a0f7
  1. 4
      app/models/form/sales/pages/buyer_live_in_value_check.rb
  2. 4
      app/models/validations/sales/soft_validations.rb
  3. 4
      config/locales/en.yml
  4. 8
      spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb
  5. 34
      spec/models/validations/sales/soft_validations_spec.rb

4
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 super
@depends_on = [ @depends_on = [
{ {
"buyer#{person_index}_not_livein?" => true, "buyer#{person_index}_livein_wrong_for_ownership_type?" => true,
}, },
] ]
@title_text = { @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" }], "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }],
} }
@informative_text = {} @informative_text = {}

4
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? mortgage_deposit_and_grant_total != value_with_discount && discounted_ownership_sale?
end end
def buyer1_not_livein? def buyer1_livein_wrong_for_ownership_type?
return unless ownershipsch && buy1livein return unless ownershipsch && buy1livein
(discounted_ownership_sale? || shared_ownership_scheme?) && buy1livein == 2 (discounted_ownership_sale? || shared_ownership_scheme?) && buy1livein == 2
end end
def buyer2_not_livein? def buyer2_livein_wrong_for_ownership_type?
return unless ownershipsch && buy2livein return unless ownershipsch && buy2livein
return unless joint_purchase? return unless joint_purchase?

4
config/locales/en.yml

@ -551,9 +551,9 @@ en:
informative_text: "Your given mortgage, deposit and grant total is £%{mortgage_deposit_and_grant_total}" informative_text: "Your given mortgage, deposit and grant total is £%{mortgage_deposit_and_grant_total}"
care_home_charges: care_home_charges:
title_text: "Care home charges should be provided if this is a care home accommodation" 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." 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." 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: devise:

8
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 it "has correct depends_on" do
expect(page.depends_on).to eq([ expect(page.depends_on).to eq([
{ {
"buyer1_not_livein?" => true, "buyer1_livein_wrong_for_ownership_type?" => true,
}, },
]) ])
end end
@ -38,7 +38,7 @@ RSpec.describe Form::Sales::Pages::BuyerLiveInValueCheck, type: :model do
it "has the correct title_text" do it "has the correct title_text" do
expect(page.title_text).to eq({ 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" }], "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }],
}) })
end end
@ -49,14 +49,14 @@ RSpec.describe Form::Sales::Pages::BuyerLiveInValueCheck, type: :model do
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([ expect(page.depends_on).to eq([
{ {
"buyer2_not_livein?" => true, "buyer2_livein_wrong_for_ownership_type?" => true,
}, },
]) ])
end end
it "has the correct title_text" do it "has the correct title_text" do
expect(page.title_text).to eq({ 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" }], "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }],
}) })
end end

34
spec/models/validations/sales/soft_validations_spec.rb

@ -914,7 +914,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
end end
describe "#buyer1_not_livein?" do describe "#buyer1_livein_wrong_for_ownership_type?" do
context "when it's a shared ownership" do context "when it's a shared ownership" do
let(:record) { FactoryBot.build(:sales_log, ownershipsch: 1) } let(:record) { FactoryBot.build(:sales_log, ownershipsch: 1) }
@ -924,7 +924,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns true" do it "returns true" do
expect(record).to be_buyer1_not_livein expect(record).to be_buyer1_livein_wrong_for_ownership_type
end end
end end
@ -934,7 +934,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns false" do 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 end
end end
@ -948,7 +948,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns true" do it "returns true" do
expect(record).to be_buyer1_not_livein expect(record).to be_buyer1_livein_wrong_for_ownership_type
end end
end end
@ -958,7 +958,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns false" do 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 end
end end
@ -972,7 +972,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns false" do 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 end
@ -982,7 +982,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns false" do 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 end
end end
@ -995,12 +995,12 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns false" do 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 end
end end
describe "#buyer2_not_livein?" do describe "#buyer2_livein_wrong_for_ownership_type?" do
context "when it's a shared ownership" do context "when it's a shared ownership" do
let(:record) { FactoryBot.build(:sales_log, ownershipsch: 1, jointpur: 1) } let(:record) { FactoryBot.build(:sales_log, ownershipsch: 1, jointpur: 1) }
@ -1010,7 +1010,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns true" do it "returns true" do
expect(record).to be_buyer2_not_livein expect(record).to be_buyer2_livein_wrong_for_ownership_type
end end
end end
@ -1020,7 +1020,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns false" do 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 end
@ -1031,7 +1031,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns false" do 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 end
end end
@ -1045,7 +1045,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns true" do it "returns true" do
expect(record).to be_buyer2_not_livein expect(record).to be_buyer2_livein_wrong_for_ownership_type
end end
end end
@ -1055,7 +1055,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns false" do 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 end
end end
@ -1069,7 +1069,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns false" do 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 end
@ -1079,7 +1079,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns false" do 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 end
end end
@ -1092,7 +1092,7 @@ RSpec.describe Validations::Sales::SoftValidations do
end end
it "returns false" do 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 end
end end

Loading…
Cancel
Save