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

Fix destroying of team member not working #7000

Closed
wants to merge 6 commits into from

Conversation

ErikSchierboom
Copy link
Member

No description provided.

inverse_of: :github_team_memberships,
dependent: :destroy
optional: true
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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?

@@ -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) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
user { create(:user, uid: SecureRandom.hex) }
user

I'm not sure why you need to specify uidhere. 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)
Copy link
Member

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
Copy link
Member

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.

Copy link
Member Author

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).

Copy link
Member Author

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.

@ErikSchierboom
Copy link
Member Author

Superseded by #7027

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants