Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/bundler/rails-7.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
willc-work authored Oct 15, 2024
2 parents e9e85d4 + 6523d45 commit 43427fc
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 14 deletions.
4 changes: 4 additions & 0 deletions app/models/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions app/models/completed_user_journey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
#
#------------------------------------------------------------------------------
17 changes: 12 additions & 5 deletions app/services/check_answers/section_lister_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/initializers/rails_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@
"ActiveStorage::VariantRecord",
"ActionText::RichText",
"ActionText::EncryptedRichText",
"Provider",
)
end
Original file line number Diff line number Diff line change
@@ -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
11 changes: 6 additions & 5 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
13 changes: 13 additions & 0 deletions spec/flows/early_result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions spec/flows/under_eighteen_flow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 43427fc

Please sign in to comment.