Browse Source

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

pull/1326/head
Arthur Campbell 3 years ago
parent
commit
114c0a64cb
  1. 9
      app/models/form/sales/pages/buyer_previous.rb
  2. 8
      app/models/form/sales/questions/buyer_previous.rb
  3. 3
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  4. 21
      spec/models/form/sales/pages/buyer_previous_spec.rb
  5. 25
      spec/models/form/sales/questions/buyer_previous_spec.rb
  6. 3
      spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb

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

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

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

@ -1,9 +1,9 @@
class Form::Sales::Questions::BuyerPrevious < ::Form::Question class Form::Sales::Questions::BuyerPrevious < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page, joint_purchase:)
super super(id, hsh, page)
@id = "soctenant" @id = "soctenant"
@check_answer_label = "Buyer was a registered provider, housing association or local authority tenant immediately before this sale?" @check_answer_label = "#{joint_purchase ? 'Any buyers were' : 'Buyer was a'} registered provider#{'s' if joint_purchase}, housing association or local authority tenant#{'s' if joint_purchase} immediately before this sale?"
@header = "Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?" @header = "#{joint_purchase ? 'Were any of the buyers' : 'Was the buyer a'} private registered provider#{'s' if joint_purchase}, housing association or local authority tenant#{'s' if joint_purchase} immediately before this sale?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
end end

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

@ -18,7 +18,8 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::HandoverDate.new(nil, nil, self), Form::Sales::Pages::HandoverDate.new(nil, nil, self),
Form::Sales::Pages::HandoverDateCheck.new(nil, nil, self), Form::Sales::Pages::HandoverDateCheck.new(nil, nil, self),
Form::Sales::Pages::LaNominations.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::PreviousBedrooms.new(nil, nil, self),
Form::Sales::Pages::PreviousPropertyType.new(nil, nil, self), Form::Sales::Pages::PreviousPropertyType.new(nil, nil, self),
Form::Sales::Pages::PreviousTenure.new(nil, nil, self), Form::Sales::Pages::PreviousTenure.new(nil, nil, self),

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

@ -1,11 +1,12 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Pages::BuyerPrevious, type: :model do 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(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } let(:subsection) { instance_double(Form::Subsection) }
let(:joint_purchase) { false }
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
@ -16,7 +17,7 @@ RSpec.describe Form::Sales::Pages::BuyerPrevious, type: :model do
end end
it "has the correct id" do it "has the correct id" do
expect(page.id).to eq("buyer_previous") expect(page.id).to eq("example")
end end
it "has the correct header" do 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 it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end 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 end

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

@ -1,11 +1,12 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Questions::BuyerPrevious, type: :model do 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_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:joint_purchase) { true }
it "has correct page" do it "has correct page" do
expect(question.page).to eq(page) 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") expect(question.id).to eq("soctenant")
end end
it "has the correct header" do context "when a joint purchase" do
expect(question.header).to eq("Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?") 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 end
it "has the correct check_answer_label" do context "when not a joint purchase" do
expect(question.check_answer_label).to eq("Buyer was a registered provider, housing association or local authority tenant immediately before this sale?") 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 end
it "has the correct type" do it "has the correct type" do

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

@ -24,7 +24,8 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do
handover_date handover_date
handover_date_check handover_date_check
la_nominations la_nominations
buyer_previous buyer_previous_joint_purchase
buyer_previous_not_joint_purchase
previous_bedrooms previous_bedrooms
previous_property_type previous_property_type
shared_ownership_previous_tenure shared_ownership_previous_tenure

Loading…
Cancel
Save