Skip to content

Commit

Permalink
Only update maintainer status when added to track team (#7054)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Sep 4, 2024
1 parent 3c61ce7 commit b401d48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/commands/github/team_member/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def call
return unless user

user.github_team_memberships.find_or_create_by!(team_name:).tap do |team_member|
User::UpdateMaintainer.(user) if team_member.previously_new_record?
User::UpdateMaintainer.(user) if team_member.previously_new_record? && team_member.track_id
end
end

Expand Down
11 changes: 11 additions & 0 deletions test/commands/github/team_member/create_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Github::TeamMember::CreateTest < ActiveSupport::TestCase
github_uid = '137131'
team_name = 'fsharp'

create(:track, slug: team_name)
user = create(:user, uid: github_uid)
User::UpdateMaintainer.expects(:call).with(user).once

Expand All @@ -38,6 +39,16 @@ class Github::TeamMember::CreateTest < ActiveSupport::TestCase
Github::TeamMember::Create.(github_uid, team_name)
end

test "noop when team is not track team" do
github_uid = '137131'
team_name = 'configlet'
user = create(:user, uid: github_uid)

User::UpdateMaintainer.expects(:call).with(user).never

Github::TeamMember::Create.(github_uid, team_name)
end

test "idempotent" do
user_id = '137131'
team_name = 'fsharp'
Expand Down

0 comments on commit b401d48

Please sign in to comment.