Browse Source

CLDC-3766: Ensure copy for sales Q78 is found correctly for 2024 logs (#2790)

* CLDC-3766: Ensure copy for Q78 is found correctly

* Fix tests
pull/2793/head v0.4.85
Rachael Booth 1 month ago committed by GitHub
parent
commit
aeae0c1806
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/models/form/sales/questions/staircase.rb
  2. 1
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  3. 4
      app/models/form/subsection.rb
  4. 4
      spec/models/form/sales/pages/staircase_spec.rb
  5. 4
      spec/models/form/sales/questions/staircase_spec.rb

2
app/models/form/sales/questions/staircase.rb

@ -2,7 +2,7 @@ class Form::Sales::Questions::Staircase < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "staircase" @id = "staircase"
@copy_key = "sales.#{page.subsection.id}.staircasing" @copy_key = "sales.#{page.subsection.copy_key}.staircasing"
@type = "radio" @type = "radio"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

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

@ -4,6 +4,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
@id = "shared_ownership_scheme" @id = "shared_ownership_scheme"
@label = "Shared ownership scheme" @label = "Shared ownership scheme"
@depends_on = [{ "ownershipsch" => 1, "setup_completed?" => true }] @depends_on = [{ "ownershipsch" => 1, "setup_completed?" => true }]
@copy_key = "sale_information"
end end
def pages def pages

4
app/models/form/subsection.rb

@ -14,6 +14,10 @@ class Form::Subsection
delegate :form, to: :section delegate :form, to: :section
def copy_key
@copy_key ||= @id
end
def questions def questions
@questions ||= pages.flat_map(&:questions) @questions ||= pages.flat_map(&:questions)
end end

4
spec/models/form/sales/pages/staircase_spec.rb

@ -8,7 +8,7 @@ RSpec.describe Form::Sales::Pages::Staircase, type: :model do
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) }
context "when start year is 2024" do context "when start year is 2024" do
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)), id: "sale_information") } let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)), id: "shared_ownership_scheme", copy_key: "sale_information") }
before do before do
allow(subsection.form).to receive(:start_year_2025_or_later?).and_return(false) allow(subsection.form).to receive(:start_year_2025_or_later?).and_return(false)
@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Pages::Staircase, type: :model do
end end
context "when start year is >= 2025" do context "when start year is >= 2025" do
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)), id: "setup") } let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)), id: "setup", copy_key: "setup") }
before do before do
allow(subsection.form).to receive(:start_year_2025_or_later?).and_return(true) allow(subsection.form).to receive(:start_year_2025_or_later?).and_return(true)

4
spec/models/form/sales/questions/staircase_spec.rb

@ -7,7 +7,7 @@ RSpec.describe Form::Sales::Questions::Staircase, type: :model do
let(:question_definition) { nil } let(:question_definition) { nil }
context "when start year is 2024" do context "when start year is 2024" do
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1)), id: "sale_information")) } let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1)), id: "shared_ownership_scheme", copy_key: "sale_information")) }
before do before do
allow(page.subsection.form).to receive(:start_year_2025_or_later?).and_return(false) allow(page.subsection.form).to receive(:start_year_2025_or_later?).and_return(false)
@ -43,7 +43,7 @@ RSpec.describe Form::Sales::Questions::Staircase, type: :model do
end end
context "when start year is 2025" do context "when start year is 2025" do
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1)), id: "setup")) } let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1)), id: "setup", copy_key: "setup")) }
before do before do
allow(page.subsection.form).to receive(:start_year_2025_or_later?).and_return(true) allow(page.subsection.form).to receive(:start_year_2025_or_later?).and_return(true)

Loading…
Cancel
Save