Skip to content

Store school email domains#787

Merged
PetarSimonovic merged 14 commits into
mainfrom
store-school-email-domains
May 19, 2026
Merged

Store school email domains#787
PetarSimonovic merged 14 commits into
mainfrom
store-school-email-domains

Conversation

@PetarSimonovic
Copy link
Copy Markdown
Contributor

@PetarSimonovic PetarSimonovic commented Apr 21, 2026

Status

Closes #1325

What's changed?

  • Add a school_email_domains table
  • Add a SchoolEmailDomain model
  • Add a SchoolEmailDomainValidator that normalises and checks domains
  • Update association on School
  • Add valid_domain? method on School
  • Add and update specs

Copilot AI review requested due to automatic review settings April 21, 2026 11:05
@cla-bot cla-bot Bot added the cla-signed label Apr 21, 2026
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

Introduces first-class storage for school email domains by adding a dedicated table/model and wiring it into the School domain model, with accompanying specs.

Changes:

  • Added school_email_domains table with a composite unique index per school.
  • Added SchoolEmailDomain model with before_validation normalization (strip leading @, downcase).
  • Updated School to has_many :school_email_domains and added/updated model specs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
spec/models/school_spec.rb Adds association + dependent-destroy coverage for school_email_domains.
spec/models/school_email_domain_spec.rb Adds model spec coverage for domain normalization behavior.
db/schema.rb Reflects new school_email_domains table and foreign key.
db/migrate/20260420104937_create_school_email_domains.rb Creates the new school_email_domains table and composite unique index.
app/models/school_email_domain.rb Introduces the new model and domain normalization callback.
app/models/school.rb Adds has_many :school_email_domains, dependent: :destroy.

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

Comment thread app/models/school_email_domain.rb
Comment thread spec/models/school_email_domain_spec.rb
Comment thread db/migrate/20260420104937_create_school_email_domains.rb
@PetarSimonovic PetarSimonovic force-pushed the store-school-email-domains branch from 4740867 to aff003a Compare April 21, 2026 12:38
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

Test coverage

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

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


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

Comment thread app/models/school_email_domain.rb
Comment thread spec/models/school_email_domain_spec.rb Outdated
Comment thread app/models/school_email_domain.rb Outdated
Copy link
Copy Markdown
Contributor

@fspeirs fspeirs left a comment

Choose a reason for hiding this comment

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

Overall this looks like the right approach. I have one consideration about validating domains - I feel like it would be helpful to be stricter in checking that the user hasn't typo'ed their domain or misunderstood what we are asking for.

Comment thread app/models/school_email_domain.rb Outdated
Comment thread spec/models/school_email_domain_spec.rb
@PetarSimonovic PetarSimonovic requested a review from fspeirs April 22, 2026 10:31
Copy link
Copy Markdown
Contributor

@fspeirs fspeirs left a comment

Choose a reason for hiding this comment

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

Directionally, quite correct. Just some sharpening of the normalisation approach in school_email_domain and a request for a testing method in school.rb. The lack of a testing method is non-blocking if it's coming in a separate PR.

Comment thread app/models/school_email_domain.rb Outdated
Comment thread app/models/school.rb
@peconia
Copy link
Copy Markdown
Contributor

peconia commented Apr 30, 2026

The regex we use in profile side to validate is '^\\s*(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\\.)+[A-Za-z]{2,63}\\s*$'

While it is similar, we would reject things that had a dash in the wrong place, like example.-wrong.edu, but that would be approved by this one. I also wonder about things that are domains but not email domains, like having www. or ftp. prefix to the domain. Maybe that will come down to making sure the UI is clear in what is expected, and the API level can validate some things too.

@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-3fgo5v April 30, 2026 16:15 Inactive
@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-hfpxj9 April 30, 2026 16:32 Inactive
Comment thread spec/models/school_email_domain_spec.rb
Comment thread app/models/school_email_domain.rb Outdated
@PetarSimonovic PetarSimonovic force-pushed the store-school-email-domains branch from 4fda047 to ead00de Compare April 30, 2026 16:42
@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-okmdpg April 30, 2026 16:43 Inactive
@PetarSimonovic PetarSimonovic force-pushed the store-school-email-domains branch from ead00de to 81f8ad5 Compare April 30, 2026 16:52
@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-r7dl1t April 30, 2026 16:52 Inactive
@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-vkoodl April 30, 2026 17:12 Inactive
@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-vkoodl April 30, 2026 17:18 Inactive
@PetarSimonovic PetarSimonovic force-pushed the store-school-email-domains branch from 00a63d5 to e5a847a Compare April 30, 2026 17:22
@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-vkoodl April 30, 2026 17:22 Inactive
@PetarSimonovic PetarSimonovic force-pushed the store-school-email-domains branch from e5a847a to f5eb365 Compare April 30, 2026 17:24
@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-vkoodl April 30, 2026 17:24 Inactive
@PetarSimonovic PetarSimonovic requested a review from fspeirs April 30, 2026 17:29
@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-1bslx0 May 7, 2026 14:43 Inactive
@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-xaov7e May 15, 2026 08:03 Inactive
@PetarSimonovic PetarSimonovic force-pushed the store-school-email-domains branch from c5e1590 to 62a5acb Compare May 15, 2026 08:04
@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-xaov7e May 15, 2026 08:04 Inactive
@PetarSimonovic PetarSimonovic force-pushed the store-school-email-domains branch from 62a5acb to 1e8b16a Compare May 15, 2026 08:12
@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-xaov7e May 15, 2026 08:13 Inactive
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

@PetarSimonovic PetarSimonovic force-pushed the store-school-email-domains branch from 1e8b16a to b789663 Compare May 18, 2026 15:17
@PetarSimonovic PetarSimonovic temporarily deployed to editor-api-p-store-scho-fles7a May 18, 2026 15:18 Inactive
@PetarSimonovic PetarSimonovic merged commit 916c66a into main May 19, 2026
5 checks passed
@PetarSimonovic PetarSimonovic deleted the store-school-email-domains branch May 19, 2026 08: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.

5 participants