Skip to content

Commit b9c1de5

Browse files
Refactor PatientMerger to use PatientDeleter
Jira-Issue: MAV-7067
1 parent 079fccf commit b9c1de5

2 files changed

Lines changed: 1 addition & 31 deletions

File tree

app/lib/patient_merger.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def call
181181
user: @user
182182
)
183183

184-
patient_to_destroy.reload.destroy!
184+
PatientDeleter.call(patients: Patient.where(id: patient_to_destroy.id))
185185

186186
PatientStatusUpdater.call(patient: patient_to_keep)
187187
end

spec/models/patient_spec.rb

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,36 +1446,6 @@
14461446
end
14471447
end
14481448

1449-
describe "#destroy_childless_parents" do
1450-
context "when parent has only one child" do
1451-
let(:parent) { create(:parent) }
1452-
let!(:patient) { create(:patient, parents: [parent]) }
1453-
1454-
it "destroys the parent when the patient is destroyed" do
1455-
expect { patient.destroy }.to change(Parent, :count).by(-1)
1456-
end
1457-
end
1458-
1459-
context "when parent has multiple children" do
1460-
let(:parent) { create(:parent) }
1461-
let!(:patient) { create(:patient, parents: [parent]) }
1462-
1463-
before { create(:patient, parents: [parent]) }
1464-
1465-
it "does not destroy the parent when one patient is destroyed" do
1466-
expect { patient.destroy }.not_to change(Parent, :count)
1467-
end
1468-
end
1469-
1470-
context "when patient has multiple parents" do
1471-
let!(:patient) { create(:patient, parents: create_list(:parent, 2)) }
1472-
1473-
it "destroys only the childless parents" do
1474-
expect { patient.destroy }.to change(Parent, :count).by(-2)
1475-
end
1476-
end
1477-
end
1478-
14791449
describe "#latest_pds_search_result" do
14801450
subject(:latest_pds_search_result) { patient.latest_pds_search_result }
14811451

0 commit comments

Comments
 (0)