Skip to content

Conversation

@danhalson
Copy link
Contributor

@danhalson danhalson commented Dec 19, 2025

Status

What's changed?

  • Separates onboarding logic from verification and adds a new service
  • Sets administrative_area and postal_code to required fields, to match the frontend
  • This is all wrapped behind a feature flag ENABLE_IMMEDIATE_SCHOOL_ONBOARDING
    • This will need enabling / disabling as required via terraform or locally to develop against this feature

Steps to perform after deploying to production

N/A

@cla-bot cla-bot bot added the cla-signed label Dec 19, 2025
@danhalson danhalson self-assigned this Dec 19, 2025
@danhalson danhalson marked this pull request as draft December 19, 2025 10:31
@danhalson danhalson marked this pull request as ready for review January 6, 2026 15:34
@danhalson danhalson force-pushed the 1069-add-immediate-onboarding branch from 2c1ff13 to 12f5e0a Compare January 12, 2026 09:25
Copy link
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

This pull request introduces immediate school onboarding functionality behind a feature flag ENABLE_IMMEDIATE_SCHOOL_ONBOARDING. The main changes separate the onboarding logic (role creation and Profile API registration) from the verification process, and automatically generate school codes at creation time rather than at verification time. Additionally, administrative_area and postal_code are made required fields to match frontend validation.

Changes:

  • Added SchoolOnboardingService to handle role creation and Profile API registration
  • Modified SchoolVerificationService to conditionally skip onboarding when the feature flag is enabled
  • Updated School model to generate codes automatically via after_commit callback when immediate onboarding is enabled
  • Updated School::Create operation to call onboarding service when feature flag is enabled
  • Made administrative_area and postal_code required fields on the School model

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
lib/feature_flags.rb New module defining the immediate_school_onboarding? method to check the feature flag
app/services/school_onboarding_service.rb New service extracting onboarding logic (role creation, Profile API registration)
app/services/school_verification_service.rb Modified to conditionally delegate to onboarding service based on feature flag
app/models/school.rb Added validations for new required fields, after_commit callback for code generation, refactored verify! and generate_code! methods
lib/concepts/school/operations/create.rb Added token parameter and onboarding service call within transaction
app/controllers/api/schools_controller.rb Updated to pass token parameter to School::Create
app/jobs/school_import_job.rb Updated to pass token parameter to School::Create
spec/services/school_verification_service_spec.rb Added test coverage for both feature flag states
spec/services/school_onboarding_service_spec.rb New test file for onboarding service
spec/models/school_spec.rb Updated tests for new validations and code generation behavior
spec/lib/feature_flags_spec.rb New test file for feature flag module
spec/jobs/school_import_job_spec.rb Updated test data to include new required fields
spec/features/school/showing_a_school_spec.rb Simplified test for forbidden access scenario
spec/features/school/creating_a_school_spec.rb Updated test data to include new required fields
spec/factories/school.rb Updated factory to generate new required fields using Faker
spec/concepts/school/create_spec.rb Updated all calls to include token parameter and adjusted error count expectation
lib/tasks/seeds_helper.rb Added generation of new required fields in seed helper
.env.example Documented new feature flag environment variable

danhalson and others added 2 commits January 12, 2026 12:42
…if the code fails

This is really an edge case, but because of that in the unlikely case it happens we're better off erroring and fixing it.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This was the result of a merge conflict, the original behaviour needs to be preserved

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@danhalson danhalson temporarily deployed to editor-api-p-1069-add-i-tdbnh4 January 12, 2026 12:44 Inactive
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…not called int he school concept depending on the feature flag
@jamiebenstead jamiebenstead requested a review from Copilot January 13, 2026 09:47
Copy link
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

@jamiebenstead jamiebenstead left a comment

Choose a reason for hiding this comment

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

LGTM

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