Skip to content

Commit

Permalink
🥗🧹 Tobias: Trust#destroy destroys Trust#beneficiaries
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zspencer committed Jan 29, 2024
1 parent 2289a9d commit a235550
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/furniture/tobias/trust.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions spec/tobias/trust_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "rails_helper"

RSpec.describe Tobias::Trust, type: :model do
describe "#benficiaries" do
it { is_expected.to have_many(:beneficiaries).inverse_of(:trust).dependent(:destroy) }
end
end

0 comments on commit a235550

Please sign in to comment.