Skip to content

Ownership transfer - email previous owner when nominee accepted or declined - #1038

Merged
DNR500 merged 2 commits into
mainfrom
ownership-transfer-email-owner-accepted-or-delined
Sep 29, 2026
Merged

DNR500 merged 2 commits into
mainfrom
ownership-transfer-email-owner-accepted-or-delined

Conversation

@DNR500

@DNR500 DNR500 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Issue: #1792

Sends email that lets the previous owner know what happened to the ownership transfer they started.

What this does

  • If the invited teacher accepts, the previous owner gets an email confirming ownership has been handed over
  • If the invited teacher declines instead, the previous owner gets an email letting them know, so they can nominate someone else
  • Both emails follow the same pattern already used for the "transfer cancelled" and "you're the new owner" emails — nothing new architecturally, just filling in the gap for the previous owner

@cla-bot cla-bot Bot added the cla-signed label Sep 28, 2026
@github-actions

Copy link
Copy Markdown

Test coverage

93.74% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/36449545303

@DNR500
DNR500 marked this pull request as ready for review September 28, 2026 16:18
Copilot AI lite review requested due to automatic review settings September 28, 2026 16:18
@raspberrypiherokubot
raspberrypiherokubot temporarily deployed to editor-api-p-ownership--0zud0b September 28, 2026 16:18 Inactive

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Resolve missing-recipient handling and perform the ownership role transition, or correct the completion email’s claims.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds emails to the previous owner when an ownership transfer is completed or declined.

Changes:

  • Adds mailer actions, templates, and previews.
  • Enqueues notifications from ownership-transfer callbacks.
  • Expands model and mailer specs.

Review findings:

  • Mailer recipients can be nil when the previous owner lookup fails.
  • Completing a transfer does not update ownership roles, despite the email claiming it does.
File Reviewed change Findings
spec/​models/​ownership_transfer_spec.rb Tests notification callbacks. —
spec/​mailers/​school_ownership_mailer_spec.rb Tests recipients and email content. —
spec/​mailers/​previews/​school_ownership_mailer_preview.rb Adds mailer previews. —
app/​views/​school_ownership_mailer/​decline_ownership_transfer_previous_owner.text.erb Adds decline notification content. —
app/​views/​school_ownership_mailer/​complete_ownership_transfer_previous_owner.text.erb Adds completion notification content. Claims roles changed when they are not updated.
app/​models/​ownership_transfer.rb Enqueues previous-owner notifications. Ownership roles are not transitioned before notification.
app/​mailers/​school_ownership_mailer.rb Defines completion and decline emails. Can enqueue mail with no recipient when lookup returns nil.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

previous_owner = users_by_id[ownership_transfer.requested_by_user_id]
@previous_owner_name = previous_owner&.name.presence || 'there'

mail(to: previous_owner&.email,

Ownership of the Code Classroom account for <%= @school.name %> has been successfully transferred to the new owner.

You are no longer the owner of this school. As part of the transfer, your role has automatically been changed to Teacher. You will still be able to create students, classes and projects within the account.

@cocomarine cocomarine 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.

LGTM

@DNR500
DNR500 merged commit 9499195 into main Sep 29, 2026
9 checks passed
@DNR500
DNR500 deleted the ownership-transfer-email-owner-accepted-or-delined branch September 29, 2026 08:16

This branch was previously deployed

1 inactive deployment
editor-api-p-ownership--0zud0b — 1dca2be4 Deployed Sep 28, 2026 by raspberrypiherokubot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants