-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Fix destroying of team member not working #7000
Conversation
app/models/github/team_member.rb
Outdated
inverse_of: :github_team_memberships, | ||
dependent: :destroy | ||
optional: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is currently a not null constraint on the database, so this isn't actually optional. So either the DB or this line should be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed things a bit, but the factory is not setup well enough apparently:
ActiveRecord::RecordInvalid: Validation failed: User must exist
Any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is green now, so I guess this is an old comment?
68a5940
to
5331749
Compare
74975f5
to
1f587ce
Compare
@@ -1,6 +1,6 @@ | |||
FactoryBot.define do | |||
factory :github_team_member, class: 'Github::TeamMember' do | |||
user_id { SecureRandom.hex } | |||
user { create(:user, uid: SecureRandom.hex) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user { create(:user, uid: SecureRandom.hex) } | |
user |
I'm not sure why you need to specify uid
here. I think just a normal user is fine.
@@ -6,6 +6,8 @@ class Webhooks::ProcessMembershipUpdateTest < ActiveSupport::TestCase | |||
team_name = 'team11' | |||
org = 'exercism' | |||
|
|||
create(:user, uid: user_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you also need a provider
here?
dependent: :destroy | ||
belongs_to :user, | ||
primary_key: :uid, | ||
inverse_of: :github_team_memberships |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is right. Looking at the schema, there is a user_id
column. So the primary key is the user_id
column on this table.
We can remove the user_id column, in which case we need to remove that column and add a uid
column instead. But I feel like we should just be referencing a normal user_id
instinctively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be better, as user_id
is currently actually the uid
(it's named user ID in github).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original idea was to decouple the table as we might want to query non-DB users, but that hasn't really happend. I'll do a separate PR to fix this. I'll also check the organization members.
Superseded by #7027 |
No description provided.