Skip to content

Commit

Permalink
[CRIMAPP-1485] Fix under 18 and bypass dwp dev tools (#1248)
Browse files Browse the repository at this point in the history
* Fix under 18 and bypass dwp dev tools

* Fix linting error

* Fix linting error
  • Loading branch information
hiboabd authored Nov 13, 2024
1 parent a82bcad commit 648c89e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
32 changes: 25 additions & 7 deletions app/controllers/developer_tools/crime_applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ def mark_as_returned
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def bypass_dwp
find_or_create_applicant
find_or_create_partner_detail

crime_application.update(
navigation_stack: [
edit_steps_client_has_partner_path(crime_application),
edit_steps_client_details_path(crime_application),
edit_steps_client_has_nino_path(crime_application),
edit_steps_client_is_means_tested_path(crime_application),
edit_steps_client_case_type_path(crime_application),
edit_steps_client_residence_type_path(crime_application),
edit_steps_client_contact_details_path(crime_application),
edit_steps_nino_path(crime_application, subject: 'client'),
edit_steps_client_has_partner_path(crime_application),
edit_steps_client_relationship_status_path(crime_application),
edit_steps_dwp_benefit_type_path(crime_application),
edit_steps_dwp_benefit_check_result_path(crime_application),
]
Expand All @@ -58,9 +64,8 @@ def under18_bypass

crime_application.update(
navigation_stack: [
edit_steps_client_has_partner_path(crime_application),
edit_steps_client_details_path(crime_application),
edit_steps_client_contact_details_path(crime_application),
edit_steps_client_is_means_tested_path(crime_application),
edit_steps_client_case_type_path(crime_application),
]
)
Expand All @@ -75,8 +80,7 @@ def crime_application
@crime_application ||= current_crime_application || initialize_crime_application
end

# rubocop:disable Metrics/MethodLength
def find_or_create_applicant(overrides = {})
def find_or_create_applicant(overrides = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
Applicant.find_or_initialize_by(crime_application_id: crime_application.id).tap do |record|
surname, details = DWP::MockBenefitCheckService::KNOWN.to_a.sample

Expand All @@ -85,18 +89,32 @@ def find_or_create_applicant(overrides = {})
last_name: surname,
other_names: '',
date_of_birth: overrides.fetch(:dob, details[:dob]),
has_nino: overrides.fetch(:has_nino, 'yes'),
nino: overrides.fetch(:nino, details[:nino]),
has_arc: overrides.fetch(:has_arc, 'no'),
arc: overrides.fetch(:nino, nil),
benefit_type: overrides.fetch(:benefit_type, 'universal_credit'),
last_jsa_appointment_date: overrides.fetch(:last_jsa_appointment_date, nil),
benefit_check_result: overrides.fetch(:benefit_check_result, true),
residence_type: overrides.fetch(:residence_type, 'none'),
correspondence_address_type: CorrespondenceType::PROVIDERS_OFFICE_ADDRESS,
telephone_number: '123456789',
)
end
end
# rubocop:enable Metrics/MethodLength

def find_or_create_case
Case.find_or_initialize_by(crime_application_id: crime_application.id)
end

def find_or_create_partner_detail(overrides = {})
PartnerDetail.find_or_initialize_by(crime_application_id: crime_application.id).tap do |record|
record.update(
has_partner: overrides.fetch(:has_partner, 'no'),
relationship_status: overrides.fetch(:relationship_status, 'single'),
)
end
end
end
end
# :nocov:
2 changes: 1 addition & 1 deletion app/models/concerns/type_of_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def change_in_financial_circumstances?
alias cifc? change_in_financial_circumstances?

def appeal_no_changes?
return false unless kase&.appeal_original_app_submitted == 'yes'
return false unless kase.present? && kase.appeal_original_app_submitted == 'yes'

kase.case_type == CaseType::APPEAL_TO_CROWN_COURT.to_s &&
kase.appeal_financial_circumstances_changed == 'no'
Expand Down

0 comments on commit 648c89e

Please sign in to comment.