diff --git a/app/models/form/page.rb b/app/models/form/page.rb index 7a5c4bf87..c1c09c362 100644 --- a/app/models/form/page.rb +++ b/app/models/form/page.rb @@ -25,7 +25,7 @@ class Form::Page delegate :form, to: :subsection def copy_key - @copy_key ||= "#{form.type}.#{subsection.id}.#{questions[0].id}" + @copy_key ||= "#{form.type}.#{subsection.copy_key}.#{questions[0].id}" end def header diff --git a/app/models/form/question.rb b/app/models/form/question.rb index 9409350f6..05eec89dd 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -51,7 +51,7 @@ class Form::Question delegate :form, to: :subsection def copy_key - @copy_key ||= "#{form.type}.#{subsection.id}.#{id}" + @copy_key ||= "#{form.type}.#{subsection.copy_key}.#{id}" end def check_answer_label diff --git a/app/models/form/sales/pages/buyer_interview.rb b/app/models/form/sales/pages/buyer_interview.rb index c6a43690b..4398e434a 100644 --- a/app/models/form/sales/pages/buyer_interview.rb +++ b/app/models/form/sales/pages/buyer_interview.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::BuyerInterview < ::Form::Page def initialize(id, hsh, subsection, joint_purchase:) super(id, hsh, subsection) @joint_purchase = joint_purchase - @copy_key = "sales.#{subsection.id}.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" + @copy_key = "sales.#{subsection.copy_key}.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" end def questions diff --git a/app/models/form/sales/pages/deposit.rb b/app/models/form/sales/pages/deposit.rb index 4870a3c35..b204227b2 100644 --- a/app/models/form/sales/pages/deposit.rb +++ b/app/models/form/sales/pages/deposit.rb @@ -3,7 +3,6 @@ class Form::Sales::Pages::Deposit < ::Form::Page super(id, hsh, subsection) @ownershipsch = ownershipsch @optional = optional - @copy_key = "sales.sale_information.deposit" end def questions diff --git a/app/models/form/sales/pages/deposit_discount.rb b/app/models/form/sales/pages/deposit_discount.rb index 84fcbb45f..3fae9c0f8 100644 --- a/app/models/form/sales/pages/deposit_discount.rb +++ b/app/models/form/sales/pages/deposit_discount.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::DepositDiscount < ::Form::Page def initialize(id, hsh, subsection, optional:) super(id, hsh, subsection) @optional = optional - @copy_key = "sales.sale_information.cashdis" end def questions diff --git a/app/models/form/sales/pages/discount.rb b/app/models/form/sales/pages/discount.rb index 2d632985e..38d675a77 100644 --- a/app/models/form/sales/pages/discount.rb +++ b/app/models/form/sales/pages/discount.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::Discount < ::Form::Page def initialize(id, hsh, subsection) super @id = "discount" - @copy_key = "sales.sale_information.discount" @depends_on = [{ "right_to_buy?" => true, }] diff --git a/app/models/form/sales/pages/equity.rb b/app/models/form/sales/pages/equity.rb index 9bf3050a0..46eec40a3 100644 --- a/app/models/form/sales/pages/equity.rb +++ b/app/models/form/sales/pages/equity.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::Equity < ::Form::Page def initialize(id, hsh, subsection) super @id = "equity" - @copy_key = "sales.sale_information.equity" end def questions diff --git a/app/models/form/sales/pages/extra_borrowing.rb b/app/models/form/sales/pages/extra_borrowing.rb index c6ddb705a..d86db67b5 100644 --- a/app/models/form/sales/pages/extra_borrowing.rb +++ b/app/models/form/sales/pages/extra_borrowing.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::ExtraBorrowing < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @ownershipsch = ownershipsch - @copy_key = "sales.sale_information.extrabor" @description = "" @subsection = subsection @depends_on = [{ diff --git a/app/models/form/sales/pages/grant.rb b/app/models/form/sales/pages/grant.rb index 2f96701c5..1d11fba82 100644 --- a/app/models/form/sales/pages/grant.rb +++ b/app/models/form/sales/pages/grant.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::Grant < ::Form::Page def initialize(id, hsh, subsection) super @id = "grant" - @copy_key = "sales.sale_information.grant" @depends_on = [{ "right_to_buy?" => false, "rent_to_buy_full_ownership?" => false, diff --git a/app/models/form/sales/pages/monthly_rent.rb b/app/models/form/sales/pages/monthly_rent.rb index 943e47cff..29f0d895f 100644 --- a/app/models/form/sales/pages/monthly_rent.rb +++ b/app/models/form/sales/pages/monthly_rent.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::MonthlyRent < ::Form::Page def initialize(id, hsh, subsection) super @id = "monthly_rent" - @copy_key = "sales.sale_information.mrent" end def questions diff --git a/app/models/form/sales/pages/mortgage_amount.rb b/app/models/form/sales/pages/mortgage_amount.rb index 41fba167c..e6a722853 100644 --- a/app/models/form/sales/pages/mortgage_amount.rb +++ b/app/models/form/sales/pages/mortgage_amount.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::MortgageAmount < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @ownershipsch = ownershipsch - @copy_key = "sales.sale_information.mortgage" @depends_on = [{ "mortgage_used?" => true }] end diff --git a/app/models/form/sales/pages/mortgage_lender.rb b/app/models/form/sales/pages/mortgage_lender.rb index 87646a514..6db3c01df 100644 --- a/app/models/form/sales/pages/mortgage_lender.rb +++ b/app/models/form/sales/pages/mortgage_lender.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::MortgageLender < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @ownershipsch = ownershipsch - @copy_key = "sales.sale_information.mortgagelender" @description = "" @subsection = subsection @depends_on = [{ diff --git a/app/models/form/sales/pages/mortgage_lender_other.rb b/app/models/form/sales/pages/mortgage_lender_other.rb index 903d6518f..f71089377 100644 --- a/app/models/form/sales/pages/mortgage_lender_other.rb +++ b/app/models/form/sales/pages/mortgage_lender_other.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::MortgageLenderOther < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @ownershipsch = ownershipsch - @copy_key = "sales.sale_information.mortgagelenderother" @description = "" @subsection = subsection @depends_on = [{ diff --git a/app/models/form/sales/pages/mortgage_length.rb b/app/models/form/sales/pages/mortgage_length.rb index 76c46694a..dbc01a695 100644 --- a/app/models/form/sales/pages/mortgage_length.rb +++ b/app/models/form/sales/pages/mortgage_length.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::MortgageLength < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @ownershipsch = ownershipsch - @copy_key = "sales.sale_information.mortlen" @depends_on = [{ "mortgageused" => 1, }] diff --git a/app/models/form/sales/pages/mortgageused.rb b/app/models/form/sales/pages/mortgageused.rb index ab48b0c2d..f9d8eae2e 100644 --- a/app/models/form/sales/pages/mortgageused.rb +++ b/app/models/form/sales/pages/mortgageused.rb @@ -1,7 +1,6 @@ class Form::Sales::Pages::Mortgageused < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) - @copy_key = "sales.sale_information.mortgageused" @ownershipsch = ownershipsch end diff --git a/app/models/form/sales/pages/previous_bedrooms.rb b/app/models/form/sales/pages/previous_bedrooms.rb index 26b3ef050..214632d49 100644 --- a/app/models/form/sales/pages/previous_bedrooms.rb +++ b/app/models/form/sales/pages/previous_bedrooms.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::PreviousBedrooms < ::Form::Page def initialize(id, hsh, subsection) super @id = "previous_bedrooms" - @copy_key = "sales.sale_information.frombeds" @depends_on = [ { "soctenant" => 1, diff --git a/app/models/form/sales/pages/previous_property_type.rb b/app/models/form/sales/pages/previous_property_type.rb index c5dd4f66a..26669d774 100644 --- a/app/models/form/sales/pages/previous_property_type.rb +++ b/app/models/form/sales/pages/previous_property_type.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::PreviousPropertyType < ::Form::Page def initialize(id, hsh, subsection) super @id = "previous_property_type" - @copy_key = "sales.sale_information.fromprop" @description = "" @subsection = subsection @depends_on = [ diff --git a/app/models/form/sales/pages/previous_tenure.rb b/app/models/form/sales/pages/previous_tenure.rb index c35b6bd67..0f4a4b250 100644 --- a/app/models/form/sales/pages/previous_tenure.rb +++ b/app/models/form/sales/pages/previous_tenure.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::PreviousTenure < ::Form::Page def initialize(id, hsh, subsection) super @id = "shared_ownership_previous_tenure" - @copy_key = "sales.sale_information.socprevten" @header = "" @description = "" @subsection = subsection diff --git a/app/models/form/sales/pages/privacy_notice.rb b/app/models/form/sales/pages/privacy_notice.rb index 40c441d3e..c99ee3397 100644 --- a/app/models/form/sales/pages/privacy_notice.rb +++ b/app/models/form/sales/pages/privacy_notice.rb @@ -1,7 +1,7 @@ class Form::Sales::Pages::PrivacyNotice < ::Form::Page def initialize(id, hsh, subsection, joint_purchase:) super(id, hsh, subsection) - @copy_key = "sales.#{subsection.id}.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" + @copy_key = "sales.#{subsection.copy_key}.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" @joint_purchase = joint_purchase end diff --git a/app/models/form/sales/pages/resale.rb b/app/models/form/sales/pages/resale.rb index 6f4cd24e2..ffdbbc046 100644 --- a/app/models/form/sales/pages/resale.rb +++ b/app/models/form/sales/pages/resale.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::Resale < ::Form::Page def initialize(id, hsh, subsection) super @id = "resale" - @copy_key = "sales.sale_information.resale" @depends_on = [ { "staircase" => 2, diff --git a/app/models/form/sales/pages/staircase.rb b/app/models/form/sales/pages/staircase.rb index 1413abadc..c96da3f3f 100644 --- a/app/models/form/sales/pages/staircase.rb +++ b/app/models/form/sales/pages/staircase.rb @@ -3,7 +3,7 @@ class Form::Sales::Pages::Staircase < ::Form::Page super @id = "staircasing" @depends_on = [{ "ownershipsch" => 1 }] - @copy_key = "sales.#{subsection.id}.staircasing" + @copy_key = "sales.#{subsection.copy_key}.staircasing" end def questions diff --git a/app/models/form/sales/pages/value_shared_ownership.rb b/app/models/form/sales/pages/value_shared_ownership.rb index c2212c787..200563053 100644 --- a/app/models/form/sales/pages/value_shared_ownership.rb +++ b/app/models/form/sales/pages/value_shared_ownership.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::ValueSharedOwnership < ::Form::Page def initialize(id, hsh, subsection) super @id = "value_shared_ownership" - @copy_key = "sales.sale_information.value" end def questions diff --git a/app/models/form/sales/questions/buyer_interview.rb b/app/models/form/sales/questions/buyer_interview.rb index b49b57807..50c290904 100644 --- a/app/models/form/sales/questions/buyer_interview.rb +++ b/app/models/form/sales/questions/buyer_interview.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::BuyerInterview < ::Form::Question def initialize(id, hsh, page, joint_purchase:) super(id, hsh, page) @id = "noint" - @copy_key = "sales.#{subsection.id}.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" + @copy_key = "sales.#{subsection.copy_key}.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/deposit_amount.rb b/app/models/form/sales/questions/deposit_amount.rb index 41586cd94..6f2b98ce8 100644 --- a/app/models/form/sales/questions/deposit_amount.rb +++ b/app/models/form/sales/questions/deposit_amount.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:, optional:) super(id, hsh, subsection) @id = "deposit" - @copy_key = "sales.sale_information.deposit" @type = "numeric" @min = 0 @max = 999_999 diff --git a/app/models/form/sales/questions/deposit_discount.rb b/app/models/form/sales/questions/deposit_discount.rb index 289e3962c..bfc5f425d 100644 --- a/app/models/form/sales/questions/deposit_discount.rb +++ b/app/models/form/sales/questions/deposit_discount.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::DepositDiscount < ::Form::Question def initialize(id, hsh, page) super @id = "cashdis" - @copy_key = "sales.sale_information.cashdis" @type = "numeric" @min = 0 @max = 999_999 diff --git a/app/models/form/sales/questions/discount.rb b/app/models/form/sales/questions/discount.rb index 3807a8cfc..5dcf1f125 100644 --- a/app/models/form/sales/questions/discount.rb +++ b/app/models/form/sales/questions/discount.rb @@ -3,7 +3,6 @@ class Form::Sales::Questions::Discount < ::Form::Question super @id = "discount" @type = "numeric" - @copy_key = "sales.sale_information.discount" @min = 0 @max = form.start_year_2024_or_later? ? 70 : 100 @step = 0.1 diff --git a/app/models/form/sales/questions/equity.rb b/app/models/form/sales/questions/equity.rb index 4aae785b8..7a2a4ce5b 100644 --- a/app/models/form/sales/questions/equity.rb +++ b/app/models/form/sales/questions/equity.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::Equity < ::Form::Question def initialize(id, hsh, page) super @id = "equity" - @copy_key = "sales.sale_information.equity" @type = "numeric" @min = 0 @max = 100 diff --git a/app/models/form/sales/questions/extra_borrowing.rb b/app/models/form/sales/questions/extra_borrowing.rb index e3cd0ff7e..2ad13ef5d 100644 --- a/app/models/form/sales/questions/extra_borrowing.rb +++ b/app/models/form/sales/questions/extra_borrowing.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::ExtraBorrowing < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "extrabor" - @copy_key = "sales.sale_information.extrabor" @type = "radio" @answer_options = ANSWER_OPTIONS @page = page diff --git a/app/models/form/sales/questions/fromprop.rb b/app/models/form/sales/questions/fromprop.rb index 1a3393b7a..dec591cd0 100644 --- a/app/models/form/sales/questions/fromprop.rb +++ b/app/models/form/sales/questions/fromprop.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::Fromprop < ::Form::Question def initialize(id, hsh, page) super @id = "fromprop" - @copy_key = "sales.sale_information.fromprop" @type = "radio" @page = page @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/sales/questions/grant.rb b/app/models/form/sales/questions/grant.rb index 17361fe9c..f069fedd2 100644 --- a/app/models/form/sales/questions/grant.rb +++ b/app/models/form/sales/questions/grant.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::Grant < ::Form::Question def initialize(id, hsh, page) super @id = "grant" - @copy_key = "sales.sale_information.grant" @type = "numeric" @min = 0 @max = 999_999 diff --git a/app/models/form/sales/questions/monthly_rent.rb b/app/models/form/sales/questions/monthly_rent.rb index 7e64d8571..8e9ecfaef 100644 --- a/app/models/form/sales/questions/monthly_rent.rb +++ b/app/models/form/sales/questions/monthly_rent.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::MonthlyRent < ::Form::Question def initialize(id, hsh, page) super @id = "mrent" - @copy_key = "sales.sale_information.mrent" @type = "numeric" @min = 0 @step = 0.01 diff --git a/app/models/form/sales/questions/mortgage_amount.rb b/app/models/form/sales/questions/mortgage_amount.rb index a6ffcf26a..e0677ee18 100644 --- a/app/models/form/sales/questions/mortgage_amount.rb +++ b/app/models/form/sales/questions/mortgage_amount.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "mortgage" - @copy_key = "sales.sale_information.mortgage" @type = "numeric" @min = 1 @step = 1 diff --git a/app/models/form/sales/questions/mortgage_lender.rb b/app/models/form/sales/questions/mortgage_lender.rb index a4aa55f17..96bf9e5b3 100644 --- a/app/models/form/sales/questions/mortgage_lender.rb +++ b/app/models/form/sales/questions/mortgage_lender.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::MortgageLender < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "mortgagelender" - @copy_key = "sales.sale_information.mortgagelender" @type = "select" @page = page @bottom_guidance_partial = "mortgage_lender" diff --git a/app/models/form/sales/questions/mortgage_lender_other.rb b/app/models/form/sales/questions/mortgage_lender_other.rb index 49876efb0..8cd5de8fb 100644 --- a/app/models/form/sales/questions/mortgage_lender_other.rb +++ b/app/models/form/sales/questions/mortgage_lender_other.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::MortgageLenderOther < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "mortgagelenderother" - @copy_key = "sales.sale_information.mortgagelenderother" @type = "text" @page = page @ownershipsch = ownershipsch diff --git a/app/models/form/sales/questions/mortgage_length.rb b/app/models/form/sales/questions/mortgage_length.rb index 877818b98..5d94fc832 100644 --- a/app/models/form/sales/questions/mortgage_length.rb +++ b/app/models/form/sales/questions/mortgage_length.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "mortlen" - @copy_key = "sales.sale_information.mortlen" @type = "numeric" @min = 0 @max = 60 diff --git a/app/models/form/sales/questions/mortgageused.rb b/app/models/form/sales/questions/mortgageused.rb index e4a101072..3c3c42840 100644 --- a/app/models/form/sales/questions/mortgageused.rb +++ b/app/models/form/sales/questions/mortgageused.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::Mortgageused < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "mortgageused" - @copy_key = "sales.sale_information.mortgageused" @type = "radio" @answer_options = ANSWER_OPTIONS @ownershipsch = ownershipsch diff --git a/app/models/form/sales/questions/previous_bedrooms.rb b/app/models/form/sales/questions/previous_bedrooms.rb index d29da208a..dd243137d 100644 --- a/app/models/form/sales/questions/previous_bedrooms.rb +++ b/app/models/form/sales/questions/previous_bedrooms.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::PreviousBedrooms < ::Form::Question def initialize(id, hsh, page) super @id = "frombeds" - @copy_key = "sales.sale_information.frombeds" @type = "numeric" @width = 5 @min = 1 diff --git a/app/models/form/sales/questions/previous_tenure.rb b/app/models/form/sales/questions/previous_tenure.rb index 55b103f0d..794d449b5 100644 --- a/app/models/form/sales/questions/previous_tenure.rb +++ b/app/models/form/sales/questions/previous_tenure.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::PreviousTenure < ::Form::Question def initialize(id, hsh, page) super @id = "socprevten" - @copy_key = "sales.sale_information.socprevten" @type = "radio" @page = page @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/sales/questions/privacy_notice.rb b/app/models/form/sales/questions/privacy_notice.rb index 5e73e7a3a..ace2c9ec1 100644 --- a/app/models/form/sales/questions/privacy_notice.rb +++ b/app/models/form/sales/questions/privacy_notice.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question def initialize(id, hsh, page, joint_purchase:) super(id, hsh, page) @id = "privacynotice" - @copy_key = "sales.#{subsection.id}.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" + @copy_key = "sales.#{subsection.copy_key}.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" @type = "checkbox" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @joint_purchase = joint_purchase diff --git a/app/models/form/sales/questions/resale.rb b/app/models/form/sales/questions/resale.rb index 0026adb48..2417960b4 100644 --- a/app/models/form/sales/questions/resale.rb +++ b/app/models/form/sales/questions/resale.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::Resale < ::Form::Question def initialize(id, hsh, page) super @id = "resale" - @copy_key = "sales.sale_information.resale" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/value.rb b/app/models/form/sales/questions/value.rb index 257344fa2..1d258899d 100644 --- a/app/models/form/sales/questions/value.rb +++ b/app/models/form/sales/questions/value.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::Value < ::Form::Question def initialize(id, hsh, page) super @id = "value" - @copy_key = "sales.sale_information.value" @type = "numeric" @min = 0 @step = 1 diff --git a/app/models/form/sales/subsections/discounted_ownership_scheme.rb b/app/models/form/sales/subsections/discounted_ownership_scheme.rb index 63ce4af47..c74dcd262 100644 --- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb +++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb @@ -4,6 +4,7 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection @id = "discounted_ownership_scheme" @label = "Discounted ownership scheme" @depends_on = [{ "ownershipsch" => 2, "setup_completed?" => true }] + @copy_key = "sale_information" end def pages diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb index af63c8179..afa0f4a69 100644 --- a/app/models/form/sales/subsections/outright_sale.rb +++ b/app/models/form/sales/subsections/outright_sale.rb @@ -4,6 +4,7 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection @id = "outright_sale" @label = "Outright sale" @depends_on = [{ "ownershipsch" => 3, "setup_completed?" => true }] + @copy_key = "sale_information" end def pages diff --git a/spec/models/form/lettings/questions/homeless_spec.rb b/spec/models/form/lettings/questions/homeless_spec.rb index f18a8ece7..7f2c1b054 100644 --- a/spec/models/form/lettings/questions/homeless_spec.rb +++ b/spec/models/form/lettings/questions/homeless_spec.rb @@ -28,10 +28,6 @@ RSpec.describe Form::Lettings::Questions::Homeless, type: :model do }) end - it "has no hint text" do - expect(question.hint_text).to be_empty - end - it "has the correct check_answers_card_number" do expect(question.check_answers_card_number).to eq(0) end diff --git a/spec/models/form/page_spec.rb b/spec/models/form/page_spec.rb index 9315fb237..3ec929fc4 100644 --- a/spec/models/form/page_spec.rb +++ b/spec/models/form/page_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Form::Page, type: :model do let(:enabled) { true } let(:depends_on_met) { true } let(:form) { instance_double(Form, depends_on_met:, type: "form-type", start_date: Time.utc(2024, 12, 25)) } - let(:subsection) { instance_double(Form::Subsection, depends_on:, enabled?: enabled, form:, id: "subsection-id") } + let(:subsection) { instance_double(Form::Subsection, depends_on:, enabled?: enabled, form:, id: "subsection-id", copy_key: "subsection-copy-key") } let(:page_id) { "net_income" } let(:questions) { [["earnings", { "conditional_for" => { "age1": nil }, "type" => "radio" }], %w[incfreq]] } let(:page_definition) do @@ -25,7 +25,7 @@ RSpec.describe Form::Page, type: :model do end it "sets copy_key in the default style" do - expect(page.copy_key).to eq("#{form.type}.#{subsection.id}.#{questions[0][0]}") + expect(page.copy_key).to eq("#{form.type}.#{subsection.copy_key}.#{questions[0][0]}") end context "when header is not provided" do diff --git a/spec/models/form/question_spec.rb b/spec/models/form/question_spec.rb index 651d167bd..8b9ab7a85 100644 --- a/spec/models/form/question_spec.rb +++ b/spec/models/form/question_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Form::Question, type: :model do let(:inferred_check_answers_value) { [{ "condition" => { "postcode_known" => 0 }, "value" => "Weekly" }] } let(:form) { instance_double(Form, depends_on_met:, conditional_question_conditions:, type: "form-type", start_date: Time.utc(2024, 12, 25)) } - let(:subsection) { instance_double(Form::Subsection, form:, id: "subsection-id") } + let(:subsection) { instance_double(Form::Subsection, form:, id: "subsection-id", copy_key: "subsection-copy-key") } let(:page) { instance_double(Form::Page, subsection:, routed_to?: true, questions: form_questions) } let(:question_id) { "earnings" } let(:question_definition) do @@ -39,7 +39,7 @@ RSpec.describe Form::Question, type: :model do end it "sets copy_key in the default style" do - expect(question.copy_key).to eq("#{form.type}.#{subsection.id}.#{question_id}") + expect(question.copy_key).to eq("#{form.type}.#{subsection.copy_key}.#{question_id}") end context "when copy is not provided" do diff --git a/spec/models/form/sales/pages/buyer_interview_spec.rb b/spec/models/form/sales/pages/buyer_interview_spec.rb index f7c6bbb70..ea707a0fe 100644 --- a/spec/models/form/sales/pages/buyer_interview_spec.rb +++ b/spec/models/form/sales/pages/buyer_interview_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Form::Sales::Pages::BuyerInterview, type: :model do let(:page_id) { "buyer_interview" } let(:page_definition) { nil } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false) } - let(:subsection) { instance_double(Form::Subsection, form:, id: "setup") } + let(:subsection) { instance_double(Form::Subsection, form:, id: "setup", copy_key: "subsection_copy_key") } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -24,43 +24,23 @@ RSpec.describe Form::Sales::Pages::BuyerInterview, type: :model do expect(page.description).to be_nil end - context "when form is before 2024" do - let(:subsection) { instance_double(Form::Subsection, form:, id: "household_characteristics") } + context "when there are joint buyers" do + subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) } - context "when there are joint buyers" do - subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) } + let(:subsection) { instance_double(Form::Subsection, form:, copy_key: "subsection_copy_key") } - it "has the expected copy_key" do - expect(page.copy_key).to eq("sales.household_characteristics.noint.joint_purchase") - end - end - - context "when there is a single buyer" do - subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) } - - it "has the expected copy_key" do - expect(page.copy_key).to eq("sales.household_characteristics.noint.not_joint_purchase") - end + it "has the expected copy_key" do + expect(page.copy_key).to eq("sales.subsection_copy_key.noint.joint_purchase") end end - context "when form is after 2024" do - let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2024_or_later?: true) } - - context "when there are joint buyers" do - subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) } - - it "has the expected copy_key" do - expect(page.copy_key).to eq("sales.setup.noint.joint_purchase") - end - end + context "when there is a single buyer" do + subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) } - context "when there is a single buyer" do - subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) } + let(:subsection) { instance_double(Form::Subsection, form:, copy_key: "subsection_copy_key") } - it "has the expected copy_key" do - expect(page.copy_key).to eq("sales.setup.noint.not_joint_purchase") - end + it "has the expected copy_key" do + expect(page.copy_key).to eq("sales.subsection_copy_key.noint.not_joint_purchase") end end end diff --git a/spec/models/form/sales/pages/privacy_notice_spec.rb b/spec/models/form/sales/pages/privacy_notice_spec.rb index 80be7ae66..8b21e7b9e 100644 --- a/spec/models/form/sales/pages/privacy_notice_spec.rb +++ b/spec/models/form/sales/pages/privacy_notice_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do let(:page_id) { "privacy_notice" } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, id: "setup") } + let(:subsection) { instance_double(Form::Subsection, id: "setup", copy_key: "setup") } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false) } before do @@ -31,20 +31,10 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do context "when there are joint buyers" do subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) } - context "when the form start year is before 2024" do - let(:subsection) { instance_double(Form::Subsection, id: "household_characteristics") } + let(:subsection) { instance_double(Form::Subsection, id: "subsection_id", copy_key: "subsection_copy_key") } - it "has the expected copy_key" do - expect(page.copy_key).to eq("sales.household_characteristics.privacynotice.joint_purchase") - end - end - - context "when the form start year is after 2024" do - let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2024_or_later?: true) } - - it "has the expected copy_key" do - expect(page.copy_key).to eq("sales.setup.privacynotice.joint_purchase") - end + it "has the expected copy_key" do + expect(page.copy_key).to eq("sales.subsection_copy_key.privacynotice.joint_purchase") end it "has correct depends_on" do @@ -55,20 +45,10 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do context "when there is a single buyer" do subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) } - context "when the form start year is before 2024" do - let(:subsection) { instance_double(Form::Subsection, id: "household_characteristics") } - - it "has the expected copy_key" do - expect(page.copy_key).to eq("sales.household_characteristics.privacynotice.not_joint_purchase") - end - end - - context "when the form start year is after 2024" do - let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2024_or_later?: true) } + let(:subsection) { instance_double(Form::Subsection, id: "subsection_id", copy_key: "subsection_copy_key") } - it "has the expected copy_key" do - expect(page.copy_key).to eq("sales.setup.privacynotice.not_joint_purchase") - end + it "has the expected copy_key" do + expect(page.copy_key).to eq("sales.subsection_copy_key.privacynotice.not_joint_purchase") end it "has correct depends_on" do diff --git a/spec/models/form/sales/questions/buyer_interview_spec.rb b/spec/models/form/sales/questions/buyer_interview_spec.rb index 0db43407f..e812f6146 100644 --- a/spec/models/form/sales/questions/buyer_interview_spec.rb +++ b/spec/models/form/sales/questions/buyer_interview_spec.rb @@ -6,7 +6,8 @@ RSpec.describe Form::Sales::Questions::BuyerInterview, type: :model do let(:question_id) { nil } let(:question_definition) { nil } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: true) } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "setup")) } + let(:subsection) { instance_double(Form::Subsection, form:, copy_key: "setup") } + let(:page) { instance_double(Form::Page, subsection:) } it "has correct page" do expect(question.page).to eq(page) @@ -34,42 +35,20 @@ RSpec.describe Form::Sales::Questions::BuyerInterview, type: :model do context "when there are joint buyers" do subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) } - context "when the form start year is before 2024" do - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "household_characteristics")) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 3, 1), start_year_2024_or_later?: false) } + let(:subsection) { instance_double(Form::Subsection, form:, copy_key: "subsection_copy_key") } - it "has the expected copy_key" do - expect(question.copy_key).to eq("sales.household_characteristics.noint.joint_purchase") - end - end - - context "when the form start year is after 2024" do - let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2024_or_later?: true) } - - it "has the expected copy_key" do - expect(question.copy_key).to eq("sales.setup.noint.joint_purchase") - end + it "has the expected copy_key" do + expect(question.copy_key).to eq("sales.subsection_copy_key.noint.joint_purchase") end end context "when there is a single buyer" do subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: false) } - context "when the form start year is before 2024" do - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "household_characteristics")) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false) } - - it "has the expected copy_key" do - expect(question.copy_key).to eq("sales.household_characteristics.noint.not_joint_purchase") - end - end - - context "when the form start year is after 2024" do - let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2024_or_later?: true) } + let(:subsection) { instance_double(Form::Subsection, form:, copy_key: "subsection_copy_key") } - it "has the expected copy_key" do - expect(question.copy_key).to eq("sales.setup.noint.not_joint_purchase") - end + it "has the expected copy_key" do + expect(question.copy_key).to eq("sales.subsection_copy_key.noint.not_joint_purchase") end end end diff --git a/spec/models/form/sales/questions/privacy_notice_spec.rb b/spec/models/form/sales/questions/privacy_notice_spec.rb index 5f764c7af..f279c6bf9 100644 --- a/spec/models/form/sales/questions/privacy_notice_spec.rb +++ b/spec/models/form/sales/questions/privacy_notice_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } - let(:subsection) { instance_double(Form::Subsection, id: "setup") } + let(:subsection) { instance_double(Form::Subsection, id: "setup", copy_key: "setup") } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } before do @@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do end context "when the form year is before 2024" do - let(:subsection) { instance_double(Form::Subsection, id: "household_characteristics") } + let(:subsection) { instance_double(Form::Subsection, id: "household_characteristics", copy_key: "household_characteristics") } before do allow(form).to receive(:start_year_2024_or_later?).and_return(false) diff --git a/spec/models/form/sales/questions/uprn_confirmation_spec.rb b/spec/models/form/sales/questions/uprn_confirmation_spec.rb index 0e54155b6..c6f7fd723 100644 --- a/spec/models/form/sales/questions/uprn_confirmation_spec.rb +++ b/spec/models/form/sales/questions/uprn_confirmation_spec.rb @@ -25,10 +25,6 @@ RSpec.describe Form::Sales::Questions::UprnConfirmation, type: :model do expect(question.derived?(nil)).to be false end - it "has the correct unanswered_error_message" do - expect(question.unanswered_error_message).to eq("You must answer #{format_ending(I18n.t('forms.2023.sales.property_information.uprn_confirmed.check_answer_label'))}") - end - describe "notification_banner" do context "when address is not present" do it "returns nil" do diff --git a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb index a573103a3..3fa57571b 100644 --- a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb @@ -56,6 +56,10 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model expect(discounted_ownership_scheme.id).to eq("discounted_ownership_scheme") end + it "has the correct copy key" do + expect(discounted_ownership_scheme.copy_key).to eq("sale_information") + end + it "has the correct label" do expect(discounted_ownership_scheme.label).to eq("Discounted ownership scheme") end diff --git a/spec/models/form/sales/subsections/outright_sale_spec.rb b/spec/models/form/sales/subsections/outright_sale_spec.rb index 52941d0a9..b91553939 100644 --- a/spec/models/form/sales/subsections/outright_sale_spec.rb +++ b/spec/models/form/sales/subsections/outright_sale_spec.rb @@ -109,6 +109,10 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do expect(outright_sale.id).to eq("outright_sale") end + it "has the correct copy key" do + expect(outright_sale.copy_key).to eq("sale_information") + end + it "has the correct label" do expect(outright_sale.label).to eq("Outright sale") end diff --git a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb index 4c546d58c..51e2ee60d 100644 --- a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb @@ -65,6 +65,10 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do expect(shared_ownership_scheme.id).to eq("shared_ownership_scheme") end + it "has the correct copy key" do + expect(shared_ownership_scheme.copy_key).to eq("sale_information") + end + it "has the correct label" do expect(shared_ownership_scheme.label).to eq("Shared ownership scheme") end diff --git a/spec/models/form/subsection_spec.rb b/spec/models/form/subsection_spec.rb index 8a4b9d3d7..0215e51dc 100644 --- a/spec/models/form/subsection_spec.rb +++ b/spec/models/form/subsection_spec.rb @@ -19,6 +19,10 @@ RSpec.describe Form::Subsection, type: :model do expect(subsection.id).to eq(subsection_id) end + it "has a copy_key defaulting to the id" do + expect(subsection.copy_key).to eq(subsection_id) + end + it "has a label" do expect(subsection.label).to eq("Household characteristics") end