Skip to content

Fix gem transfer when co-owners are already organization members - #6768

Open
anton-bondaronok wants to merge 1 commit into
masterfrom
ab/fix-gem-transfer-existing-org-members
Open

Fix gem transfer when co-owners are already organization members#6768
anton-bondaronok wants to merge 1 commit into
masterfrom
ab/fix-gem-transfer-existing-org-members

Conversation

@anton-bondaronok

Copy link
Copy Markdown

Description

Closes #6740

Transfer used to always insert new memberships from approved invites. That failed when a co-owner was already in the target org: the duplicate Membership was invalid and unsaved, then OrganizationMailer.user_invited raised ActiveJob::SerializationError.

Existing members are now skipped. They stay off the users step, their org role is unchanged, and they are not emailed. Their individual gem ownership is still removed so they access the gem through the organization. Role changes continue to go through organization management. New invitees are created and emailed as before.

How to test

  1. Transfer a gem whose co-owner is already in the org (seeded rubygem1 / gem-maintainer to RubyGems). Confirm succeeds; membership role is unchanged; gem ownership is removed; no invite email; the user does not appear on the users step.
  2. Mix of new invitee + existing member: new membership created + emailed; existing member unchanged except gem ownership removed.
  3. Non-member set to Outside Contributor: no membership; gem ownership demoted to maintainer.
  4. bin/rails test test/models/rubygem_transfer_test.rb test/functional/rubygems/transfer/users_controller_test.rb

Skip existing memberships instead of inserting duplicates.
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.77%. Comparing base (baa58ad) to head (69b5c31).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6768   +/-   ##
=======================================
  Coverage   97.77%   97.77%           
=======================================
  Files         531      531           
  Lines       11443    11450    +7     
=======================================
+ Hits        11188    11195    +7     
  Misses        255      255           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@anton-bondaronok anton-bondaronok self-assigned this Aug 13, 2026

@brian-penguin brian-penguin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍🏻

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.

Gem transfer fails when a gem co-owner is already an organization member

2 participants