Repository navigation
Add ForwardEmail sync tests; fix crash when the account has no domains - #12095
Merged
Merged
Conversation
SyncForwardEmailService#inner_call returned nil when ForwardEmail listed no domains, but CivilService#call! expects a result, so SyncEmailForwardingForDomainJob died with `undefined method 'exception' for nil`. Return success instead. Tests run the service against a fake HTTP adapter, with the real middleware in front of it (auth, form encoding, JSON, raising on errors), so they check what is actually sent: creating, updating and deleting aliases, duplicate cleanup, catch-alls, creating missing domains, pagination, partial failures, and authentication. Also covers the job's API key handling. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013mDr1nhgyzST2iPzCzMcCd
Contributor
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Tests for the ForwardEmail sync (
SyncForwardEmailServiceandSyncEmailForwardingForDomainJob, both at 0%), which keeps ForwardEmail's aliases in line with our staff positions, event email, and email routes. If this misbehaves, mail is silently dropped or misrouted.The service builds its own Faraday connection, so the tests wrap
Faraday.newto put a fake HTTP adapter behind the service's real middleware (basic auth, form encoding, JSON parsing, raising on HTTP errors). They check what's actually sent over the wire:*for a catch-allcalland raises fromcall!Bug found (fixed here)
inner_callreturnednil(return if existing_domains.empty?) when ForwardEmail listed no domains.CivilService#call!callsresult.exception, so the job died withundefined method 'exception' for nil. It now returnssuccess. Whether bailing out when there are no domains is the right behavior (versus creating them) is a separate question; I kept the existing behavior and just made it not crash.Noted, not changed
sync_mappings_for_domainhas areturn if mappings.nil?that runs aftermappingswas already used, so it can never trigger.paginate_requestbuilds aURIand query it never uses.Also adds
.rubocop_todo.ymlforLint/MissingSuperon this service (same as the other CivilService classes) and afrozen_string_literalcomment, so the file passes the pre-commit rubocop.🤖 Generated with Claude Code
https://claude.ai/code/session_013mDr1nhgyzST2iPzCzMcCd