From 33b7ff800a92317f36a8b8bb4d2f6c781bcab672 Mon Sep 17 00:00:00 2001 From: MazOneTwoOne <76905544+MazOneTwoOne@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:49:33 +0100 Subject: [PATCH 1/3] - exclude `providers` model from rails admin --- config/initializers/rails_admin.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb index ad33c95c8..42c965d51 100644 --- a/config/initializers/rails_admin.rb +++ b/config/initializers/rails_admin.rb @@ -62,5 +62,6 @@ "ActiveStorage::VariantRecord", "ActionText::RichText", "ActionText::EncryptedRichText", + "Provider", ) end From c36b7950b3157815b3a0b48cbcfefd6d58dc8bd8 Mon Sep 17 00:00:00 2001 From: MazOneTwoOne <76905544+MazOneTwoOne@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:34:30 +0100 Subject: [PATCH 2/3] - add `early_result_type` to CompletedUserJourney --- app/models/completed_user_journey.rb | 9 +++++---- ...dd_early_result_type_to_completed_user_journeys.rb | 11 +++++++++++ db/schema.rb | 11 ++++++----- 3 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20241010143225_add_early_result_type_to_completed_user_journeys.rb diff --git a/app/models/completed_user_journey.rb b/app/models/completed_user_journey.rb index 34de26b4c..790803aac 100644 --- a/app/models/completed_user_journey.rb +++ b/app/models/completed_user_journey.rb @@ -12,11 +12,11 @@ class CompletedUserJourney < ApplicationRecord # partner boolean false false # person_over_60 boolean false false # passported boolean false false -# main_dwelling_owned boolean false false -# vehicle_owned boolean false false -# smod_assets boolean false false +# main_dwelling_owned boolean true false +# vehicle_owned boolean true false +# smod_assets boolean true false # outcome character varying false false -# capital_contribution boolean false false +# capital_contribution boolean true false # income_contribution boolean false false # completed date true false # form_downloaded boolean true false false @@ -25,5 +25,6 @@ class CompletedUserJourney < ApplicationRecord # client_age character varying true false # session jsonb true false # office_code character varying true false +# early_result_type character varying true false # #------------------------------------------------------------------------------ diff --git a/db/migrate/20241010143225_add_early_result_type_to_completed_user_journeys.rb b/db/migrate/20241010143225_add_early_result_type_to_completed_user_journeys.rb new file mode 100644 index 000000000..e5b7dcd93 --- /dev/null +++ b/db/migrate/20241010143225_add_early_result_type_to_completed_user_journeys.rb @@ -0,0 +1,11 @@ +class AddEarlyResultTypeToCompletedUserJourneys < ActiveRecord::Migration[7.1] + def change + change_table :completed_user_journeys, bulk: true do |t| + t.column :early_result_type, :string, null: true + t.change_null :main_dwelling_owned, true + t.change_null :vehicle_owned, true + t.change_null :smod_assets, true + t.change_null :capital_contribution, true + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1c897b03d..e7c2dd4bd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_07_15_104344) do +ActiveRecord::Schema[7.1].define(version: 2024_10_10_143225) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -93,11 +93,11 @@ t.boolean "partner", null: false t.boolean "person_over_60", null: false t.boolean "passported", null: false - t.boolean "main_dwelling_owned", null: false - t.boolean "vehicle_owned", null: false - t.boolean "smod_assets", null: false + t.boolean "main_dwelling_owned" + t.boolean "vehicle_owned" + t.boolean "smod_assets" t.string "outcome", null: false - t.boolean "capital_contribution", null: false + t.boolean "capital_contribution" t.boolean "income_contribution", null: false t.date "completed" t.boolean "form_downloaded", default: false @@ -106,6 +106,7 @@ t.string "client_age" t.jsonb "session" t.string "office_code" + t.string "early_result_type" t.index ["assessment_id"], name: "index_completed_user_journeys_on_assessment_id", unique: true end From 6523d45a099a36a20484304330d2ad95b9ae901d Mon Sep 17 00:00:00 2001 From: willclarke Date: Mon, 14 Oct 2024 15:16:57 +0100 Subject: [PATCH 3/3] add check for EE result (#1550) add expectation for the contents of EE check answers add nocov to fix coverage issue, there are tests covering both sides of the branch --- app/models/check.rb | 4 ++ .../check_answers/section_lister_service.rb | 17 +++++-- spec/flows/early_result_spec.rb | 13 +++++ spec/flows/under_eighteen_flow_spec.rb | 48 +++++++++++++++++++ 4 files changed, 77 insertions(+), 5 deletions(-) diff --git a/app/models/check.rb b/app/models/check.rb index b5037c2c2..75e269fa6 100644 --- a/app/models/check.rb +++ b/app/models/check.rb @@ -184,6 +184,10 @@ def owns_property_outright? Steps::Logic.owns_property_outright?(session_data) end + def gross_early_eligibility_exit? + session_data["early_eligibility_selection"] == "gross" + end + def early_ineligible_result? session_data.dig("early_result", "result") == "ineligible" end diff --git a/app/services/check_answers/section_lister_service.rb b/app/services/check_answers/section_lister_service.rb index 9b4ea6831..9a0e7f192 100644 --- a/app/services/check_answers/section_lister_service.rb +++ b/app/services/check_answers/section_lister_service.rb @@ -26,15 +26,22 @@ def call(session_data) else pre = [ Sections::Dependants.new(check), - Sections::ClientIncome.new(check), - ] - post = [Sections::Outgoings.new(check)] + # Simplecov is showing that check.under_eighteen_assets? is not being covered by a test + # we have tests in spec/flows/under_eighteen_flow_spec.rb that check with and without under_eighteen_assets + # :nocov: + (Sections::ClientIncome.new(check) if !check.under_eighteen? || check.aggregated_means? || check.under_eighteen_regular_income? || check.under_eighteen_assets?), + # :nocov: + ].compact + + post = check.gross_early_eligibility_exit? ? [] : [Sections::Outgoings.new(check)] finance_sections = if check.partner? - pre + [Sections::PartnerIncome.new(check)] + post + pre + (check.gross_early_eligibility_exit? ? [] : [Sections::PartnerIncome.new(check)]) + post else pre + post end - non_finance_sections + finance_sections + assets + assets_sections = check.gross_early_eligibility_exit? ? [] : assets + + non_finance_sections + finance_sections + assets_sections end end end diff --git a/spec/flows/early_result_spec.rb b/spec/flows/early_result_spec.rb index ff03dd989..dd8212484 100644 --- a/spec/flows/early_result_spec.rb +++ b/spec/flows/early_result_spec.rb @@ -33,6 +33,19 @@ fill_in_other_income_screen_with_friends_and_family fill_in_ineligible_gross_income_screen(choice: "Skip remaining questions") confirm_screen("check_answers") + expect(all(".govuk-summary-card__title").map(&:text)) + .to eq( + ["Client age", + "Partner and passporting", + "Level of help", + "Type of matter", + "Type of immigration or asylum matter", + "Number of dependants", + "Employment status", + "Client employment income 1", + "Client benefits", + "Client other income"], + ) end it "back links work as expected" do diff --git a/spec/flows/under_eighteen_flow_spec.rb b/spec/flows/under_eighteen_flow_spec.rb index 8be6425fa..97df5c6c5 100644 --- a/spec/flows/under_eighteen_flow_spec.rb +++ b/spec/flows/under_eighteen_flow_spec.rb @@ -36,6 +36,54 @@ end end + context "with under 18 changing answers" do + before do + fill_in_client_age_screen(choice: "Under 18") + fill_in_level_of_help_screen(choice: "Civil controlled work or family mediation") + fill_in_under_18_controlled_legal_rep_screen(choice: "No") + fill_in_aggregated_means_screen(choice: "No") + fill_in_regular_income_screen(choice: "No") + fill_in_under_eighteen_assets_screen(choice: "No") + fill_in_forms_until(:check_answers) + end + + it "shows correct sections for under 18 no means test" do + expect(all(".govuk-summary-card__title").map(&:text)) + .to eq( + [ + "Client age", + "Level of help", + "Means tests for under 18s", + ], + ) + end + + it "show correct sections when answers are changed" do + within "#table-under_eighteen_assets" do + find('a[aria-label="Change under 18 assets"]').click + end + fill_in_under_eighteen_assets_screen(choice: "Yes") + fill_in_forms_until(:check_answers) + expect(all(".govuk-summary-card__title").map(&:text)) + .to eq( + ["Client age", + "Partner and passporting", + "Level of help", + "Means tests for under 18s", + "Type of matter", + "Number of dependants", + "Employment status", + "Client benefits", + "Client other income", + "Client outgoings and deductions", + "Home client lives in", + "Housing costs", + "Client other property", + "Client assets"], + ) + end + end + context "with u18 controlled checks with aggregated means" do before do fill_in_client_age_screen(choice: "Under 18")