Skip to content

test: cover DeliveryMethods::Sms and CustomOrgLinkPolicy::Scope (#6833)#7005

Open
augustocbx wants to merge 1 commit into
rubyforgood:mainfrom
augustocbx:6833-sms-delivery-and-custom-org-link-policy-scope-specs
Open

test: cover DeliveryMethods::Sms and CustomOrgLinkPolicy::Scope (#6833)#7005
augustocbx wants to merge 1 commit into
rubyforgood:mainfrom
augustocbx:6833-sms-delivery-and-custom-org-link-policy-scope-specs

Conversation

@augustocbx

Copy link
Copy Markdown

What github issue is this PR for, if any?

Part of #6833

What changed, and why?

Issue #6833 lists app/notifications/delivery_methods/sms.rb (43.8% line coverage) and app/policies/custom_org_link_policy.rb (50%) among the remaining low-coverage Ruby files (controllers were already handled in #6841 and #6855). This PR covers both:

  • spec/notifications/delivery_methods/sms_spec.rb — replaced the pending stub with real specs: an SMS with the flagged-case-contact message and the shortened case contact edit URL is sent via Twilio when the sender is a casa admin or supervisor, and nothing is sent when the sender is a volunteer. Uses the existing WebMockHelper short.io/Twilio stubs.
  • spec/policies/custom_org_link_policy_spec.rb — added Scope#resolve specs (the previously uncovered half of the policy): casa admins resolve only their own organization's links, supervisors and volunteers resolve none.
  • app/notifications/delivery_methods/sms.rb — memoized #sender, which called User.find on every invocation (3 queries per delivery). Prosopite, recently enabled for spec/notifications in Scan /spec/notifications for N+1s #6994, flags this as an N+1 and fails the new specs without the memoization.

How is this tested? (please write rspec and jest tests!) 💖💪

  • bundle exec rspec spec/notifications/delivery_methods/sms_spec.rb spec/policies/custom_org_link_policy_spec.rb — 10 examples, 0 failures
  • bundle exec rspec spec/notifications spec/policies spec/services/twilio_service_spec.rb spec/services/short_url_service_spec.rb spec/services/followup_service_spec.rb — 404 examples, 0 failures, 9 pending
  • bundle exec standardrb on the three touched files — no offenses

The new SMS specs fail without the memoization change (Prosopite raises NPlusOneQueriesError) and pass with it.

Screenshots please :)

No UI changes — test coverage plus a query memoization.

@github-actions github-actions Bot added 🧪 Tests Tests ruby Touches Ruby code labels Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Touches Ruby code 🧪 Tests Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant