Browse Source

CLDC-1895 pluralise various copy when joint purchase (#1326)

* update copy to handle pluralisation in the case of joint purchase for previous ownership, with associated testing changes

* update copy to handle pluralisation in the case of joint purchase for staircasing, with associated testing changes

* update copy to handle pluralisation in the case of joint purchase for buyer previous, with associated testing changes

* make minor linting changes and update the evil test about number of pages

* potential variation on how to achieve pluralisation

* use built in rails methods of pluralising copy
pull/1393/head
Arthur Campbell 2 years ago committed by GitHub
parent
commit
7d4dcb905e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      app/models/form/sales/pages/about_staircase.rb
  2. 9
      app/models/form/sales/pages/buyer_previous.rb
  3. 9
      app/models/form/sales/pages/previous_ownership.rb
  4. 8
      app/models/form/sales/questions/buyer_previous.rb
  5. 8
      app/models/form/sales/questions/prevown.rb
  6. 8
      app/models/form/sales/questions/staircase_owned.rb
  7. 3
      app/models/form/sales/subsections/income_benefits_and_savings.rb
  8. 6
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  9. 20
      config/locales/en.yml
  10. 29
      spec/models/form/sales/pages/about_staircase_spec.rb
  11. 21
      spec/models/form/sales/pages/buyer_previous_spec.rb
  12. 19
      spec/models/form/sales/pages/previous_ownership_spec.rb
  13. 25
      spec/models/form/sales/questions/buyer_previous_spec.rb
  14. 25
      spec/models/form/sales/questions/prevown_spec.rb
  15. 25
      spec/models/form/sales/questions/staircase_owned_spec.rb
  16. 6
      spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb
  17. 6
      spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb

9
app/models/form/sales/pages/about_staircase.rb

@ -1,17 +1,18 @@
class Form::Sales::Pages::AboutStaircase < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "about_staircasing"
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@joint_purchase = joint_purchase
@header = "About the staircasing transaction"
@depends_on = [{
"staircase" => 1,
"joint_purchase?" => joint_purchase,
}]
end
def questions
@questions ||= [
Form::Sales::Questions::StaircaseBought.new(nil, nil, self),
Form::Sales::Questions::StaircaseOwned.new(nil, nil, self),
Form::Sales::Questions::StaircaseOwned.new(nil, nil, self, joint_purchase: @joint_purchase),
staircase_sale_question,
].compact
end

9
app/models/form/sales/pages/buyer_previous.rb

@ -1,12 +1,13 @@
class Form::Sales::Pages::BuyerPrevious < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_previous"
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@joint_purchase = joint_purchase
@depends_on = [{ "joint_purchase?" => joint_purchase }]
end
def questions
@questions ||= [
Form::Sales::Questions::BuyerPrevious.new(nil, nil, self),
Form::Sales::Questions::BuyerPrevious.new(nil, nil, self, joint_purchase: @joint_purchase),
]
end
end

9
app/models/form/sales/pages/previous_ownership.rb

@ -1,12 +1,13 @@
class Form::Sales::Pages::PreviousOwnership < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "previous_ownership"
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@joint_purchase = joint_purchase
@depends_on = [{ "joint_purchase?" => @joint_purchase }]
end
def questions
@questions ||= [
Form::Sales::Questions::Prevown.new(nil, nil, self),
Form::Sales::Questions::Prevown.new(nil, nil, self, joint_purchase: @joint_purchase),
]
end
end

8
app/models/form/sales/questions/buyer_previous.rb

@ -1,9 +1,9 @@
class Form::Sales::Questions::BuyerPrevious < ::Form::Question
def initialize(id, hsh, page)
super
def initialize(id, hsh, page, joint_purchase:)
super(id, hsh, page)
@id = "soctenant"
@check_answer_label = "Buyer was a registered provider, housing association or local authority tenant immediately before this sale?"
@header = "Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?"
@check_answer_label = I18n.t("check_answer_labels.soctenant", count: joint_purchase ? 2 : 1)
@header = I18n.t("questions.soctenant", count: joint_purchase ? 2 : 1)
@type = "radio"
@answer_options = ANSWER_OPTIONS
end

8
app/models/form/sales/questions/prevown.rb

@ -1,9 +1,9 @@
class Form::Sales::Questions::Prevown < ::Form::Question
def initialize(id, hsh, page)
super
def initialize(id, hsh, page, joint_purchase:)
super(id, hsh, page)
@id = "prevown"
@check_answer_label = "Buyers previously owned a property"
@header = "Has the buyer previously owned a property?"
@check_answer_label = I18n.t("check_answer_labels.prevown", count: joint_purchase ? 2 : 1)
@header = I18n.t("questions.prevown", count: joint_purchase ? 2 : 1)
@type = "radio"
@answer_options = ANSWER_OPTIONS
end

8
app/models/form/sales/questions/staircase_owned.rb

@ -1,9 +1,9 @@
class Form::Sales::Questions::StaircaseOwned < ::Form::Question
def initialize(id, hsh, page)
super
def initialize(id, hsh, page, joint_purchase:)
super(id, hsh, page)
@id = "stairowned"
@check_answer_label = "Percentage the buyer now owns in total"
@header = "What percentage of the property does the buyer now own in total?"
@check_answer_label = I18n.t("check_answer_labels.stairowned", count: joint_purchase ? 2 : 1)
@header = I18n.t("questions.stairowned", count: joint_purchase ? 2 : 1)
@type = "numeric"
@width = 5
@min = 0

3
app/models/form/sales/subsections/income_benefits_and_savings.rb

@ -23,7 +23,8 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection
Form::Sales::Pages::Savings.new(nil, nil, self),
Form::Sales::Pages::SavingsValueCheck.new("savings_value_check", nil, self),
Form::Sales::Pages::DepositValueCheck.new("savings_deposit_value_check", nil, self),
Form::Sales::Pages::PreviousOwnership.new(nil, nil, self),
Form::Sales::Pages::PreviousOwnership.new("previous_ownership_joint_purchase", nil, self, joint_purchase: true),
Form::Sales::Pages::PreviousOwnership.new("previous_ownership_not_joint_purchase", nil, self, joint_purchase: false),
previous_shared_page,
].compact
end

6
app/models/form/sales/subsections/shared_ownership_scheme.rb

@ -10,14 +10,16 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
@pages ||= [
Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership", nil, self),
Form::Sales::Pages::Staircase.new(nil, nil, self),
Form::Sales::Pages::AboutStaircase.new(nil, nil, self),
Form::Sales::Pages::AboutStaircase.new("about_staircasing_joint_purchase", nil, self, joint_purchase: true),
Form::Sales::Pages::AboutStaircase.new("about_staircasing_not_joint_purchase", nil, self, joint_purchase: false),
Form::Sales::Pages::StaircaseBoughtValueCheck.new(nil, nil, self),
Form::Sales::Pages::Resale.new(nil, nil, self),
Form::Sales::Pages::ExchangeDate.new(nil, nil, self),
Form::Sales::Pages::HandoverDate.new(nil, nil, self),
Form::Sales::Pages::HandoverDateCheck.new(nil, nil, self),
Form::Sales::Pages::LaNominations.new(nil, nil, self),
Form::Sales::Pages::BuyerPrevious.new(nil, nil, self),
Form::Sales::Pages::BuyerPrevious.new("buyer_previous_joint_purchase", nil, self, joint_purchase: true),
Form::Sales::Pages::BuyerPrevious.new("buyer_previous_not_joint_purchase", nil, self, joint_purchase: false),
Form::Sales::Pages::PreviousBedrooms.new(nil, nil, self),
Form::Sales::Pages::PreviousPropertyType.new(nil, nil, self),
Form::Sales::Pages::PreviousTenure.new(nil, nil, self),

20
config/locales/en.yml

@ -538,6 +538,15 @@ en:
W: "Suitable for someone who uses a wheelchair and offers the full use of all rooms and facilities."
A: "Fitted with stairlifts, ramps, level access showers or grab rails."
N: "Not designed to wheelchair-user standards or fitted with any equipment or adaptations."
soctenant:
one: "Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?"
other: "Were any of the buyers private registered providers, housing association or local authority tenants immediately before this sale?"
prevown:
one: "Has the buyer previously owned a property?"
other: "Have any of the buyers previously owned a property?"
stairowned:
one: "What percentage of the property does the buyer now own in total?"
other: "What percentage of the property do the buyers now own in total?"
hints:
location:
@ -551,6 +560,17 @@ en:
bulk_upload:
needstype: "General needs housing includes both self-contained and shared housing without support or specific adaptations. Supported housing can include direct access hostels, group homes, residential care and nursing homes."
check_answer_labels:
soctenant:
one: "Buyer was a registered provider, housing association or local authority tenant immediately before this sale?"
other: "Any buyers were registered providers, housing association or local authority tenants immediately before this sale?"
prevown:
one: "Buyer previously owned a property"
other: "Buyers previously owned a property"
stairowned:
one: "Percentage the buyer now owns in total"
other: "Percentage the buyers now own in total"
warnings:
location:
deactivate:

29
spec/models/form/sales/pages/about_staircase_spec.rb

@ -1,11 +1,12 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::AboutStaircase, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase:) }
let(:page_id) { nil }
let(:page_id) { "an_id" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:joint_purchase) { false }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
@ -32,7 +33,7 @@ RSpec.describe Form::Sales::Pages::AboutStaircase, type: :model do
end
it "has the correct id" do
expect(page.id).to eq("about_staircasing")
expect(page.id).to eq("an_id")
end
it "has the correct header" do
@ -43,9 +44,23 @@ RSpec.describe Form::Sales::Pages::AboutStaircase, type: :model do
expect(page.description).to be_nil
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{
"staircase" => 1,
}])
context "when not a joint purchase" do
it "has correct depends_on" do
expect(page.depends_on).to eq([{
"staircase" => 1,
"joint_purchase?" => false,
}])
end
end
context "when a joint purchase" do
let(:joint_purchase) { true }
it "has correct depends_on" do
expect(page.depends_on).to eq([{
"staircase" => 1,
"joint_purchase?" => true,
}])
end
end
end

21
spec/models/form/sales/pages/buyer_previous_spec.rb

@ -1,11 +1,12 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::BuyerPrevious, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase:) }
let(:page_id) { nil }
let(:page_id) { "example" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:joint_purchase) { false }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
@ -16,7 +17,7 @@ RSpec.describe Form::Sales::Pages::BuyerPrevious, type: :model do
end
it "has the correct id" do
expect(page.id).to eq("buyer_previous")
expect(page.id).to eq("example")
end
it "has the correct header" do
@ -26,4 +27,18 @@ RSpec.describe Form::Sales::Pages::BuyerPrevious, type: :model do
it "has the correct description" do
expect(page.description).to be_nil
end
context "when sales is a joint purchase" do
let(:joint_purchase) { true }
it "has the correct depends on" do
expect(page.depends_on).to eq([{ "joint_purchase?" => true }])
end
end
context "when sales is not a joint purchase" do
it "has the correct depends on" do
expect(page.depends_on).to eq([{ "joint_purchase?" => false }])
end
end
end

19
spec/models/form/sales/pages/previous_ownership_spec.rb

@ -1,11 +1,12 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::PreviousOwnership, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase:) }
let(:page_id) { nil }
let(:page_id) { "example_id" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:joint_purchase) { true }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
@ -16,7 +17,7 @@ RSpec.describe Form::Sales::Pages::PreviousOwnership, type: :model do
end
it "has the correct id" do
expect(page.id).to eq("previous_ownership")
expect(page.id).to eq("example_id")
end
it "has the correct header" do
@ -26,4 +27,16 @@ RSpec.describe Form::Sales::Pages::PreviousOwnership, type: :model do
it "has the correct description" do
expect(page.description).to be_nil
end
it "when sale is a joint purchase has the correct depends on" do
expect(page.depends_on).to eq([{ "joint_purchase?" => true }])
end
context "when sale is not a joint purchase" do
let(:joint_purchase) { false }
it "has the correct depends on" do
expect(page.depends_on).to eq([{ "joint_purchase?" => false }])
end
end
end

25
spec/models/form/sales/questions/buyer_previous_spec.rb

@ -1,11 +1,12 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::BuyerPrevious, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase:) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:joint_purchase) { true }
it "has correct page" do
expect(question.page).to eq(page)
@ -15,12 +16,26 @@ RSpec.describe Form::Sales::Questions::BuyerPrevious, type: :model do
expect(question.id).to eq("soctenant")
end
it "has the correct header" do
expect(question.header).to eq("Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?")
context "when a joint purchase" do
it "has the correct header" do
expect(question.header).to eq("Were any of the buyers private registered providers, housing association or local authority tenants immediately before this sale?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Any buyers were registered providers, housing association or local authority tenants immediately before this sale?")
end
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyer was a registered provider, housing association or local authority tenant immediately before this sale?")
context "when not a joint purchase" do
let(:joint_purchase) { false }
it "has the correct header" do
expect(question.header).to eq("Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyer was a registered provider, housing association or local authority tenant immediately before this sale?")
end
end
it "has the correct type" do

25
spec/models/form/sales/questions/prevown_spec.rb

@ -1,11 +1,12 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Prevown, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase:) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:joint_purchase) { false }
it "has correct page" do
expect(question.page).to eq(page)
@ -15,12 +16,26 @@ RSpec.describe Form::Sales::Questions::Prevown, type: :model do
expect(question.id).to eq("prevown")
end
it "has the correct header" do
expect(question.header).to eq("Has the buyer previously owned a property?")
context "when sale is not a joint purchase" do
it "has the correct header" do
expect(question.header).to eq("Has the buyer previously owned a property?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyer previously owned a property")
end
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyers previously owned a property")
context "when sale is a joint purchase" do
let(:joint_purchase) { true }
it "has the correct header" do
expect(question.header).to eq("Have any of the buyers previously owned a property?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyers previously owned a property")
end
end
it "has the correct type" do

25
spec/models/form/sales/questions/staircase_owned_spec.rb

@ -1,11 +1,12 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::StaircaseOwned, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase:) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:joint_purchase) { false }
it "has correct page" do
expect(question.page).to eq(page)
@ -15,12 +16,26 @@ RSpec.describe Form::Sales::Questions::StaircaseOwned, type: :model do
expect(question.id).to eq("stairowned")
end
it "has the correct header" do
expect(question.header).to eq("What percentage of the property does the buyer now own in total?")
context "when a joint purchase" do
let(:joint_purchase) { true }
it "has the correct header" do
expect(question.header).to eq("What percentage of the property do the buyers now own in total?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Percentage the buyers now own in total")
end
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Percentage the buyer now owns in total")
context "when not a joint purchase" do
it "has the correct header" do
expect(question.header).to eq("What percentage of the property does the buyer now own in total?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Percentage the buyer now owns in total")
end
end
it "has the correct type" do

6
spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb

@ -35,7 +35,8 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
savings
savings_value_check
savings_deposit_value_check
previous_ownership
previous_ownership_joint_purchase
previous_ownership_not_joint_purchase
],
)
end
@ -62,7 +63,8 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
savings
savings_value_check
savings_deposit_value_check
previous_ownership
previous_ownership_joint_purchase
previous_ownership_not_joint_purchase
previous_shared
],
)

6
spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb

@ -16,14 +16,16 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do
%w[
living_before_purchase_shared_ownership
staircasing
about_staircasing
about_staircasing_joint_purchase
about_staircasing_not_joint_purchase
staircase_bought_value_check
resale
exchange_contracts
handover_date
handover_date_check
la_nominations
buyer_previous
buyer_previous_joint_purchase
buyer_previous_not_joint_purchase
previous_bedrooms
previous_property_type
shared_ownership_previous_tenure

Loading…
Cancel
Save