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