Skip to content

Commit

Permalink
AP-4170 delete dwp override if dwp result is correct
Browse files Browse the repository at this point in the history
If a DWP override has already been created and the user
returns to the confirm dwp page, if they change their
mind and accept the dwp result, delete the existing
DWP override
  • Loading branch information
agoldstone93 committed Oct 31, 2023
1 parent 4d115c9 commit cddf8e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def update
@form = Providers::ConfirmDWPNonPassportedApplicationsForm.new(form_params)

if @form.valid?
remove_dwp_override if correct_dwp_result?
update_joint_benefit_response
update_application_state
HMRC::CreateResponsesService.call(legal_aid_application) if make_hmrc_call?
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@
patch_request
expect(HMRC::CreateResponsesService).to have_received(:call).once
end

it "successfully deletes any existing dwp override" do
create(:dwp_override, legal_aid_application: application)
patch_request
expect(application.reload.dwp_override).to be_nil
end
end

context "and the solicitor wants to override the results with a non joint benefit" do
Expand Down

0 comments on commit cddf8e6

Please sign in to comment.