Skip to content

Add rake task for removing teacher role#785

Merged
mwtrew merged 1 commit intomainfrom
1318_remove-teacher-task
Apr 17, 2026
Merged

Add rake task for removing teacher role#785
mwtrew merged 1 commit intomainfrom
1318_remove-teacher-task

Conversation

@mwtrew
Copy link
Copy Markdown
Contributor

@mwtrew mwtrew commented Apr 17, 2026

Based on the instructions here:
https://digital-docs.rpf-internal.org/docs/technology/codebases-and-products/editor/processes/code-editor-for-education/removing-teachers

Key differences:

  • The instructions say to connect to Profile's Postgres instance to lookup the user ID, but we instead use the UserInfoApiClient for that here.
  • This task doesn't ask for a school, since it should not be possible for the user to have roles in more than one school (see role.rb).

Status

What's changed?

Adds Rake task to remove a user's current teacher role given their email address.

Steps to perform after deploying to production

Update https://digital-docs.rpf-internal.org/docs/technology/codebases-and-products/editor/processes/code-editor-for-education/removing-teachers.

Based on the instructions here:
https://digital-docs.rpf-internal.org/docs/technology/codebases-and-products/editor/processes/code-editor-for-education/removing-teachers

Key differences:
- The instructions say to connect to Profile's Postgres instance to
lookup the user ID, but we instead use the `UserInfoApiClient`
for that here.
- This task doesn't ask for a school, since it should not be possible
for the user to have roles in more than one school (see `role.rb`).
@cla-bot cla-bot bot added the cla-signed label Apr 17, 2026
@github-actions
Copy link
Copy Markdown

Test coverage

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

@mwtrew mwtrew marked this pull request as ready for review April 17, 2026 10:28
Copilot AI review requested due to automatic review settings April 17, 2026 10:28
Copy link
Copy Markdown
Contributor

@zetter-rpf zetter-rpf left a comment

Choose a reason for hiding this comment

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

Nice one

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an operational Rake task to remove a teacher role from a school user by email address, aligning with the documented “removing teachers” process while using UserInfoApiClient for user lookup.

Changes:

  • Introduce remove_teacher:run Rake task to delete a user’s teacher role by email.
  • Add RSpec task coverage for the new Rake task’s main success and early-exit paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/tasks/remove_teacher.rake Implements the remove_teacher:run task using UserInfoApiClient lookup and role deletion.
spec/lib/tasks/remove_teacher_spec.rb Adds task specs covering user-not-found, no-teacher-role, and successful removal scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/tasks/remove_teacher.rake
@mwtrew mwtrew merged commit 4a8bc6d into main Apr 17, 2026
9 checks passed
@mwtrew mwtrew deleted the 1318_remove-teacher-task branch April 17, 2026 11:01
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.

3 participants