Improve logic in Idv::UspsMail#mail_spammed?#1460
Merged
Conversation
zachmargolis
approved these changes
May 31, 2017
Contributor
zachmargolis
left a comment
There was a problem hiding this comment.
Looks like some spec failures in the controller, but other than that LGTM! Thanks for following up!
rspec ./spec/controllers/verify/review_controller_spec.rb:197 # Verify::ReviewController#new user has not requested too much mail does not display a success message
rspec ./spec/controllers/verify/review_controller_spec.rb:205 # Verify::ReviewController#new user has not requested too much mail displays a helpful error message
**Why**: If the `max_mail_events` Figaro key is not set on the server, or if it's set to zero, and if the user has not requested any letters, `max_events?` will return `true`, which will then cause `updated_within_last_month?` to throw a NoMethod error because it can't call `update_at` on a nil object. **How**: - Return `false` early in `mail_spammed?` if the user has not requested any letters. - Add `max_mail_events` and `max_mail_events_window_in_days` to the list of required Figaro keys. - Set `max_mail_events` to 2 in the test environment to avoid creating more entries in the DB than is necessary. - Use `#size` instead of `#count` for performance reasons.
d4591b3 to
cf9bc35
Compare
zachmargolis
added a commit
that referenced
this pull request
Jun 7, 2017
…c-2017-06-12 Adds pull request #1460 to release candidate
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.
Why: If the
max_mail_eventsFigaro key is not set on the server,or if it's set to zero, and if the user has not requested any letters,
max_events?will returntrue, which will then causeupdated_within_last_month?to throw a NoMethod error because it can'tcall
update_aton a nil object.How:
falseearly inmail_spammed?if the user has not requestedany letters.
max_mail_eventsandmax_mail_events_window_in_daysto the listof required Figaro keys.
max_mail_eventsto 2 in the test environment to avoid creatingmore entries in the DB than is necessary.
#sizeinstead of#countfor performance reasons.