Skip to content

Commit

Permalink
Add missing dependent option on User has_many assoc.
Browse files Browse the repository at this point in the history
  • Loading branch information
myabc committed Feb 25, 2025
1 parent 479c227 commit 2b138d0
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 @@ -49,6 +49,8 @@

describe "Associations" do
it { is_expected.to have_many(:emoji_reactions).dependent(:destroy) }
it { is_expected.to have_many(:oauth_grants).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 2b138d0

Please sign in to comment.