From 336dab9900aee831e73113e400609ec2ebd40c20 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 13 Nov 2017 17:16:24 +0100 Subject: Import: Destroy associated `Referential` on destroy if ready:false If the `Import`'s associated `Referential` has `ready: false`, destroy that `Referential` when the import is destroyed. Aaand looking back at the task it turns out that's not what I was supposed to do. Right, it does seem a little weird in retrospect. Instead we want to delete the `Referential`s of child imports. Refs #4962 --- spec/models/import_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'spec') diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index 7be05908a..dfb947711 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -57,6 +57,24 @@ RSpec.describe Import, type: :model do expect(ImportMessage.count).to eq(0) end + + it "must destroy its associated Referential if ready: false" do + referential = create(:referential, ready: false) + import = create(:import, referential: referential) + + import.destroy + + expect(referential).to be_destroyed + end + + it "must not destroy its associated Referential if ready: true" do + referential = create(:referential, ready: true) + import = create(:import, referential: referential) + + import.destroy + + expect(referential).not_to be_destroyed + end end describe "#notify_parent" do -- cgit v1.2.3