Send owner transfer email when requested - #1011
Conversation
Test coverage93.57% line coverage reported by SimpleCov. |
There was a problem hiding this comment.
🟡 Changes recommended
The email token URL and current-owner name rendering remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds backend persistence and email notifications for school ownership-transfer requests.
Changes:
- Adds encrypted ownership-transfer records and tokens.
- Adds HTML/text email templates, previews, factories, and specs.
- Updates local public URL configuration.
File summaries
| File | Summary |
|---|---|
spec/models/ownership_transfer_spec.rb |
Tests transfer behavior. |
spec/mailers/school_ownership_mailer_spec.rb |
Tests email rendering. |
spec/mailers/previews/school_ownership_mailer_preview.rb |
Adds mailer preview. |
spec/mailers/previews/invitation_preview.rb |
Updates invitation preview URL. |
spec/factories/ownership_transfer.rb |
Adds transfer factory. |
db/schema.rb |
Records schema changes. |
db/migrate/20260911104254_ownership_transfers.rb |
Creates transfer table. |
app/views/school_ownership_mailer/request_ownership_transfer.text.erb |
Plain-text email content. |
app/views/school_ownership_mailer/request_ownership_transfer.html.erb |
HTML email content. |
app/models/ownership_transfer.rb |
Defines transfer persistence and email callback. |
app/mailers/school_ownership_mailer.rb |
Builds ownership-transfer emails. |
.env.example |
Updates local public URL. |
Review details
Suppressed comments (3)
app/mailers/school_ownership_mailer.rb:9
@current_owner_nameand@nominee_nameare never assigned by this action, so every delivered email falls back toHi thereand<school name> has nominated you...; the school name is not the current owner's name. Populate these values from the transfer/request context or use neutral copy that does not substitute the school name for a person.
@school = ownership_transfer.school
@token = ownership_transfer.generate_token_for(:ownership_transfer)
app/views/school_ownership_mailer/request_ownership_transfer.html.erb:3
- The mailer never assigns
@current_owner_name, so this fallback renders the school name as the person: “Elmwood Secondary School has nominated you…”. That is factually wrong in every sent HTML email; pass the owner's name into the mailer/transfer record or use a neutral fallback until that data is available.
<p><%= @current_owner_name || @school.name %> has nominated you to become the new owner of the Code Classroom account for <%= @school.name %>.</p>
app/views/school_ownership_mailer/request_ownership_transfer.text.erb:3
- The mailer never assigns
@current_owner_name, so this fallback renders the school name as the person: “Elmwood Secondary School has nominated you…”. That is factually wrong in every sent text email; pass the owner's name into the mailer/transfer record or use a neutral fallback until that data is available.
<%= @current_owner_name || @school.name %> has nominated you to become the new owner of the Code Classroom account for <%= @school.name %>.
- Files reviewed: 12/12 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
I would follow what the invitation emails do unless there's a reason to change |
zetter-rpf
left a comment
There was a problem hiding this comment.
I've added some suggestions of things that might be able to be removed as they are not being used/set up as part of this so keeping them might be confusing.
Let me know if I can re-review
OK, removed html.erb. |
zetter-rpf
left a comment
There was a problem hiding this comment.
Approved given that we'll remove the references to tokens
Status
What for?
What's changed?
SchoolOwnershipMailerand templateownership_transferstable and its modelEmails