Update ownership transfer and mailer - #1019
Conversation
…ers" This reverts commit 3b9af1b.
Test coverage93.6% line coverage reported by SimpleCov. |
There was a problem hiding this comment.
🟡 Changes recommended
The migration and remaining validation, factory, mailer, and preview issues must be addressed.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates ownership transfers with nominee/requester metadata, status tracking, role validation, and personalized notification emails.
Changes:
- Adds transfer fields, status enum, school association, and nominee role validation.
- Personalizes ownership-transfer emails and previews.
- Updates factories and related specs.
File summaries
| File | Summary |
|---|---|
spec/models/school_spec.rb |
Tests the ownership-transfer association. |
spec/models/ownership_transfer_spec.rb |
Tests transfer validation and statuses. |
spec/mailers/school_ownership_mailer_spec.rb |
Tests personalized email content. |
spec/mailers/previews/school_ownership_mailer_preview.rb |
Updates preview user data. Moderate (3 votes): avoid permanently replacing the API client method; use a scoped stub or dependency injection. |
spec/factories/ownership_transfer.rb |
Updates transfer factory data. Moderate (2 votes): ensure default nominees have valid roles and requesters are resolvable. |
db/schema.rb |
Reflects the updated schema. |
db/migrate/20260915093824_add_nominee_and_status_to_ownership_transfers.rb |
Adds transfer columns. Critical (3 votes): stage nullable columns, backfill or clean up existing rows, then enforce constraints. |
app/views/school_ownership_mailer/request_ownership_transfer.text.erb |
Personalizes email text. |
app/models/school.rb |
Adds the ownership-transfer association. |
app/models/ownership_transfer.rb |
Adds status and nominee validation. Moderate (1 vote): validate the nominee when school_id changes as well. |
app/mailers/school_ownership_mailer.rb |
Loads nominee and requester names. Moderate (2 votes): fetch both users in one API request. |
Review details
Suppressed comments (1)
app/models/ownership_transfer.rb:24
- Because this guard only checks
nominated_user_id_changed?, changing an existing transfer'sschool_idskips the role check, allowing a nominee valid in the old school to be saved against a school where they have no owner or teacher role. Include school changes in the condition, or validate this invariant on every save.
return unless nominated_user_id_changed? && errors.blank? && school
- Files reviewed: 11/11 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Looks solid overall - the schema, validation, and mailer changes all make sense. Left a few comments from Copilot's review that I think are worth addressing before this merges (the migration's NOT NULL columns, the mailer's duplicate API calls, the factory's invalid default, and the mailer preview permanently patching the API client). Happy to approve once those are sorted. |
Status
What's changed?
nominated_user_id,requested_by_user_id, and astatusenum toownership_transferstableSchoolOwnershipMailerto include the nominee's and requester's names in the email body, with model, mailer, and preview specs updated to matchNot covered here: