Skip to content

Commit

Permalink
Add missing dependent option on User has_many assocs.
Browse files Browse the repository at this point in the history
  • Loading branch information
myabc committed Feb 25, 2025
1 parent 8dc14a5 commit 4eeb6b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ class User < Principal
# Authorized OAuth grants
has_many :oauth_grants,
class_name: "Doorkeeper::AccessGrant",
foreign_key: "resource_owner_id"
foreign_key: "resource_owner_id",
dependent: :delete_all

# User-defined oauth applications
has_many :oauth_applications,
class_name: "Doorkeeper::Application",
as: :owner
as: :owner,
dependent: :destroy

# Meeting memberships
has_many :meeting_participants,
Expand Down
2 changes: 2 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
describe "Associations" do
it { is_expected.to have_many(:emoji_reactions).dependent(:destroy) }
it { is_expected.to have_many(:reminders).with_foreign_key(:creator_id).dependent(:destroy).inverse_of(:creator) }
it { is_expected.to have_many(:oauth_grants).with_foreign_key(:resource_owner_id).dependent(:delete_all) }
it { is_expected.to have_many(:oauth_applications).dependent(:destroy) }
end

describe "with long but allowed attributes" do
Expand Down

0 comments on commit 4eeb6b4

Please sign in to comment.