Skip to content

Commit

Permalink
Add missing question option translations
Browse files Browse the repository at this point in the history
This flow was relying on the fallback to the option key which was removed
in #2005. The following exception has just occurred in production [1]:

    I18n::MissingTranslationData: translation missing:
      en-GB.flow.part-year-profit-tax-credits.have_you_stopped_trading?.options.yes

This commit adds unit tests which would've picked up the problem and adds
the missing translations.

[1]: https://errbit.publishing.service.gov.uk/apps/533c35ae0da1159384044f5f/problems/56233f4b6578634c6c971600
  • Loading branch information
floehopper committed Oct 18, 2015
1 parent 5b15c03 commit c936866
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ en-GB:
title: Have you stopped trading?
hint: This means you’re no longer running your business.
error_message: You need to select yes or no to continue.
options:
"yes": "Yes"
"no": "No"
did_you_start_trading_before_the_relevant_accounting_year?:
title: Did you start trading before %{accounting_year_begins_on}?
error_message: You need to select yes or no to continue.
options:
"yes": "Yes"
"no": "No"
when_did_you_stop_trading?:
title: When did you stop trading?
hint:
Expand All @@ -26,6 +32,9 @@ en-GB:
do_your_accounts_cover_a_12_month_period?:
title: Do your accounts cover the 12 month period up to %{accounting_year_ends_on}?
error_message: You need to select yes or no to continue.
options:
"yes": "Yes"
"no": "No"
when_did_you_start_trading?:
title: "When did you start trading?"
hint:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class PartYearProfitTaxCreditsViewTest < ActiveSupport::TestCase
@presenter = QuestionPresenter.new(@i18n_prefix, question, @state)
end

should 'have options with labels' do
assert_equal({ 'yes' => 'Yes', 'no' => 'No' }, values_vs_labels(@presenter.options))
end

should 'have a default error message' do
@state.error = 'error-message'
assert_equal 'You need to select yes or no to continue.', @presenter.error
Expand All @@ -55,6 +59,10 @@ class PartYearProfitTaxCreditsViewTest < ActiveSupport::TestCase
@presenter = QuestionPresenter.new(@i18n_prefix, question, @state)
end

should 'have options with labels' do
assert_equal({ 'yes' => 'Yes', 'no' => 'No' }, values_vs_labels(@presenter.options))
end

should 'have a default error message' do
@state.error = 'error-message'
assert_equal 'You need to select yes or no to continue.', @presenter.error
Expand All @@ -74,6 +82,10 @@ class PartYearProfitTaxCreditsViewTest < ActiveSupport::TestCase
assert_equal expected, @presenter.title
end

should 'have options with labels' do
assert_equal({ 'yes' => 'Yes', 'no' => 'No' }, values_vs_labels(@presenter.options))
end

should 'have a default error message' do
@state.error = 'error-message'
assert_equal 'You need to select yes or no to continue.', @presenter.error
Expand Down Expand Up @@ -219,5 +231,11 @@ class PartYearProfitTaxCreditsViewTest < ActiveSupport::TestCase
end
end
end

private

def values_vs_labels(options)
options.inject({}) { |h,o| h[o.value] = o.label; h }
end
end
end

0 comments on commit c936866

Please sign in to comment.