test: cover DeliveryMethods::Sms and CustomOrgLinkPolicy::Scope (#6833)#7005
Open
augustocbx wants to merge 1 commit into
Open
Conversation
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 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) andapp/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 thependingstub 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 existingWebMockHelpershort.io/Twilio stubs.spec/policies/custom_org_link_policy_spec.rb— addedScope#resolvespecs (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 calledUser.findon every invocation (3 queries per delivery). Prosopite, recently enabled forspec/notificationsin 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 failuresbundle 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 pendingbundle exec standardrbon the three touched files — no offensesThe 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.