From 845e0b0f89d222157f62339b3d2452f475fbc49a Mon Sep 17 00:00:00 2001 From: Zee Spencer <50284+zspencer@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:52:49 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=97=F0=9F=A7=B9=20`Tobias`:=20`Trust#d?= =?UTF-8?q?estroy`=20destroys=20`Trust#beneficiaries`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Again, we may want to leverage an archival system rather than destruction, but for now let's make sure we clean up when a `Trust` is detroyed. --- app/furniture/tobias/trust.rb | 2 +- spec/tobias/trust_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 spec/tobias/trust_spec.rb diff --git a/app/furniture/tobias/trust.rb b/app/furniture/tobias/trust.rb index f4cd46e7b..d8dfbc071 100644 --- a/app/furniture/tobias/trust.rb +++ b/app/furniture/tobias/trust.rb @@ -2,6 +2,6 @@ class Tobias class Trust < ApplicationRecord self.table_name = "tobias_trusts" - has_many :beneficiaries + has_many :beneficiaries, inverse_of: :trust, dependent: :destroy end end diff --git a/spec/tobias/trust_spec.rb b/spec/tobias/trust_spec.rb new file mode 100644 index 000000000..f0d61e935 --- /dev/null +++ b/spec/tobias/trust_spec.rb @@ -0,0 +1,7 @@ +require "rails_helper" + +RSpec.describe Tobias::Trust, type: :model do + describe "#benificiaries" do + it { is_expected.to have_many(:beneficiaries).inverse_of(:trust).dependent(:destroy) } + end +end