From b616e472fe5122bda58c43b7d23a5fc8f25847a0 Mon Sep 17 00:00:00 2001 From: Adam Goldstone <13471320+agoldstone93@users.noreply.github.com> Date: Mon, 30 Oct 2023 09:38:07 +0000 Subject: [PATCH] AP-4170 delete dwp override on page load --- ...confirm_dwp_non_passported_applications_controller.rb | 5 +++++ ...rm_dwp_non_passported_applications_controller_spec.rb | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/app/controllers/providers/confirm_dwp_non_passported_applications_controller.rb b/app/controllers/providers/confirm_dwp_non_passported_applications_controller.rb index 7dd384cbb58..ddcbdc6ca18 100644 --- a/app/controllers/providers/confirm_dwp_non_passported_applications_controller.rb +++ b/app/controllers/providers/confirm_dwp_non_passported_applications_controller.rb @@ -5,6 +5,7 @@ class ConfirmDWPNonPassportedApplicationsController < ProviderBaseController def show delete_check_benefits_from_history + remove_dwp_override @form = Providers::ConfirmDWPNonPassportedApplicationsForm.new(model: partner) end @@ -25,6 +26,10 @@ def update private + def remove_dwp_override + legal_aid_application.dwp_override&.destroy! + end + def partner @partner = legal_aid_application.partner end diff --git a/spec/requests/providers/confirm_dwp_non_passported_applications_controller_spec.rb b/spec/requests/providers/confirm_dwp_non_passported_applications_controller_spec.rb index 722a78c6e9b..314c73e3f00 100644 --- a/spec/requests/providers/confirm_dwp_non_passported_applications_controller_spec.rb +++ b/spec/requests/providers/confirm_dwp_non_passported_applications_controller_spec.rb @@ -71,6 +71,15 @@ expect(unescaped_response_body).not_to include(I18n.t(".providers.confirm_dwp_non_passported_applications.show.option_partner")) end end + + context "when there is a DWP override before visiting the page" do + it "is successfully deleted" do + login_as application.provider + create(:dwp_override, legal_aid_application: application) + get_request + expect(application.reload.dwp_override).to be_nil + end + end end describe "PATCH /providers/applications/:legal_aid_application_id/confirm_dwp_non_passported_applications" do