Send email domains to profile#802
Conversation
Test coverage89.35% line coverage reported by SimpleCov. |
0de41bc to
615dfc5
Compare
| it 'does not make a request to Profile API' do | ||
| update_school_email_domains_response | ||
| expect(WebMock).not_to have_requested(:patch, update_school_email_domains_url) | ||
| end |
There was a problem hiding this comment.
I'm using WebMock rather than expanding ProfileApiMock given the TODO comment at the top of that module
9570e79 to
224d636
Compare
224d636 to
99f5e7b
Compare
99f5e7b to
336bf32
Compare
Allow the client to PATCH a collection of domains
336bf32 to
9d1fef8
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the Profile integration so editor-api can send a school's student email domains to Profile, both when creating school payloads and via a new dedicated update path. It mainly adds the client/job plumbing needed for that Profile-side field and updates test fixtures to match the new school response shape.
Changes:
- Add
studentEmailDomainsto theProfileApiClient::Schoolpayload/response handling. - Add
ProfileApiClient.update_school_email_domainsplus a newUpdateSchoolEmailDomainsJob. - Update specs and mocks for the new school payload shape and PATCH endpoint.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
spec/support/profile_api_mock.rb |
Updates the Profile mock school object to include studentEmailDomains. |
spec/lib/profile_api_client_spec.rb |
Extends client specs for the new school field and adds PATCH coverage for updating email domains. |
spec/jobs/update_school_email_domains_job_spec.rb |
Adds job specs for PATCH behavior and GoodJob concurrency key generation. |
lib/profile_api_client.rb |
Adds the new school field, sends it during create, and implements the PATCH client method. |
app/jobs/update_school_email_domains_job.rb |
Introduces a background job to send school email-domain updates to Profile with retry/concurrency settings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| retry_on StandardError, wait: :polynomially_longer, attempts: 3 do |_job, e| | ||
| Sentry.capture_exception(e) | ||
| raise e | ||
| end |
|
|
||
| # rubocop:disable Naming/MethodName | ||
| School = Data.define(:id, :schoolCode, :updatedAt, :createdAt, :discardedAt) | ||
| School = Data.define(:id, :schoolCode, :studentEmailDomains, :updatedAt, :createdAt, :discardedAt) |
| it 'sends the school id, code and studentEmailDomains in the request body as json' do | ||
| create_school_response | ||
| expected_body = { id: school.id, schoolCode: school.code }.to_json | ||
| expected_body = { id: school.id, schoolCode: school.code, studentEmailDomains: [] }.to_json |
Set up a job to update Profile's school email domains
9d1fef8 to
3c2f1d4
Compare
Status
What's changed?
update_school_email_domainsmethod to ProfileApiClientManual testing
Prerequisites
Run Profile on the
school-domains-apibranch.Run editor-api.
Run editor-standalone.
Profile seeds its db with a school, alongside two users that have the owner and teacher roles required to update the school's email domains.
The school should have nothing in its
studentEmailDomainscolumn.Steps
In the editor UI, sign in as
ms.teacher@example.com.From the editor-api repo, open a console in Docker:
docker compose run --rm api rails consoleIn the browser, open DevTools → Application → Local Storage for the editor and copy the
access_token(it should start withory_at_...In the console, call ProfileApiClient.update_school_email_domains with:
token: — the access_token (string)In Profile, inspect that school again: studentEmailDomains should now list those domains.