Browse Source

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

pull/1326/head
Arthur Campbell 3 years ago
parent
commit
d0cfbf75da
  1. 9
      app/models/form/sales/pages/about_staircase.rb
  2. 8
      app/models/form/sales/questions/staircase_owned.rb
  3. 3
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  4. 21
      spec/models/form/sales/pages/about_staircase_spec.rb
  5. 17
      spec/models/form/sales/questions/staircase_owned_spec.rb
  6. 3
      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

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 = "Percentage the buyer#{'s' if joint_purchase} now own#{'s' if !joint_purchase} in total"
@header = "What percentage of the property #{joint_purchase ? 'do the buyers' : 'does the buyer'} now own in total?"
@type = "numeric"
@width = 5
@min = 0

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

@ -10,7 +10,8 @@ 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),

21
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
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

17
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,6 +16,19 @@ RSpec.describe Form::Sales::Questions::StaircaseOwned, type: :model do
expect(question.id).to eq("stairowned")
end
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
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
@ -22,6 +36,7 @@ RSpec.describe Form::Sales::Questions::StaircaseOwned, type: :model do
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
expect(question.type).to eq("numeric")

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

@ -16,7 +16,8 @@ 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

Loading…
Cancel
Save