Ensure resource_text is a string in NotificationMailer#6685
Merged
tramuntanal merged 3 commits intodevelopfrom Oct 15, 2020
Merged
Ensure resource_text is a string in NotificationMailer#6685tramuntanal merged 3 commits intodevelopfrom
resource_text is a string in NotificationMailer#6685tramuntanal merged 3 commits intodevelopfrom
Conversation
tramuntanal
approved these changes
Oct 15, 2020
resource_text is a string in NotificationMailer
tramuntanal
pushed a commit
that referenced
this pull request
Oct 15, 2020
* Ensure strings in NotificationMailer * Add specs * Ensure all events return a string on `safe_resource_text`
12 tasks
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? Why?
Sometimes the NotificationMailer fails with this error:
This means there's some event that's not properly cleaning the
resource_textvalue to make it return a String.Instead of chasing the event, this PR introduces a new method in the event base class called
safe_resource_textwhich makes sure that whatever is set by theevent#resource_textmethod is a String and it's HTML-safe.📌 Related Issues
Link your PR to an issue
None
Testing
Not sure how to find the wrong event, thus I'm not sure how to test it. Since the event is an instantiated class, I don't have the information in my error tracking application (Sentry). But if we chased the culprit, the problem might arise in other events. I think the approach in this PR is safer.
Just in case, I added tests for the new method ensuring it works as expected.
📋 Checklist
🚨 Please review the guidelines for contributing to this repository.
docs/.📷 Screenshots
None