Fix I18n::MissingTranslationData exception for checkbox 'none' option #2014
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.
This has been a problem since #2005, but it only came to light after a
production deployment. Here are couple of examples of the exceptions
we saw:
Checkbox questions have an implicit 'none' response if the user doesn't select
any of the checkboxes.
CheckboxQuestionPresenter#response_labels
translatesthe options for display in the 'Previous answers' section at the bottom of the
page.
When the translation fallbacks were removed in #2005, a
I18n::MissingTranslationData
was being raised when the user did not selectany checkboxes.
Unfortunately, this commit added a translation for the 'none' option even
though the
CheckboxSampleFlow
didn't have an explicit:none
option.Note also that the
assert_page_has_content
was changed to check for 'None'instead of 'none'.
In this commit, I've removed the translation for the 'none' option which gave
me a failing test which replicated the problem we'd seen in production.
I've fixed the failing test by adding an
if/else
statement toCheckboxQuestionPresenter#response_labels
which effectively reintroducesthe translation fallback in this very specific case.
I'm not totally happy with this solution, but hopefully it'll do for now.
You can see that the problem is fixed by visiting these two example URLs:
There should be no exception and you should see "none" in the previous answers.