Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make user_id foreign key for github team members #7027

Merged
merged 11 commits into from
Aug 14, 2024
Prev Previous commit
Next Next commit
Simplify model
  • Loading branch information
ErikSchierboom committed Aug 13, 2024
commit 800dab00b0c66231fc39351a83d43764d7bc227b
7 changes: 1 addition & 6 deletions app/models/github/team_member.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
class Github::TeamMember < ApplicationRecord
has_one :user,
foreign_key: :uid,
primary_key: :user_id,
class_name: "User",
inverse_of: :github_team_memberships,
dependent: :destroy
belongs_to :user
end
6 changes: 1 addition & 5 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ class User < ApplicationRecord

has_many :cohort_memberships, dependent: :destroy

has_many :github_team_memberships,
class_name: "Github::TeamMember",
primary_key: :uid,
inverse_of: :user,
dependent: :destroy
has_many :github_team_memberships, class_name: "Github::TeamMember", dependent: :destroy

has_many :challenges, dependent: :destroy
has_many :watched_videos, class_name: "User::WatchedVideo", dependent: :destroy
Expand Down
2 changes: 1 addition & 1 deletion test/factories/github/team_members.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :github_team_member, class: 'Github::TeamMember' do
user_id { SecureRandom.hex }
user { create :user }
team_name { SecureRandom.hex }
end
end