Skip to content

Commit c936866

Browse files
committed
Add missing question option translations
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
1 parent 5b15c03 commit c936866

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

lib/smart_answer_flows/locales/en/part-year-profit-tax-credits.yml

+9
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ en-GB:
99
title: Have you stopped trading?
1010
hint: This means you’re no longer running your business.
1111
error_message: You need to select yes or no to continue.
12+
options:
13+
"yes": "Yes"
14+
"no": "No"
1215
did_you_start_trading_before_the_relevant_accounting_year?:
1316
title: Did you start trading before %{accounting_year_begins_on}?
1417
error_message: You need to select yes or no to continue.
18+
options:
19+
"yes": "Yes"
20+
"no": "No"
1521
when_did_you_stop_trading?:
1622
title: When did you stop trading?
1723
hint:
@@ -26,6 +32,9 @@ en-GB:
2632
do_your_accounts_cover_a_12_month_period?:
2733
title: Do your accounts cover the 12 month period up to %{accounting_year_ends_on}?
2834
error_message: You need to select yes or no to continue.
35+
options:
36+
"yes": "Yes"
37+
"no": "No"
2938
when_did_you_start_trading?:
3039
title: "When did you start trading?"
3140
hint:

test/unit/smart_answer_flows/part_year_profit_tax_credits_view_test.rb

+18
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class PartYearProfitTaxCreditsViewTest < ActiveSupport::TestCase
4242
@presenter = QuestionPresenter.new(@i18n_prefix, question, @state)
4343
end
4444

45+
should 'have options with labels' do
46+
assert_equal({ 'yes' => 'Yes', 'no' => 'No' }, values_vs_labels(@presenter.options))
47+
end
48+
4549
should 'have a default error message' do
4650
@state.error = 'error-message'
4751
assert_equal 'You need to select yes or no to continue.', @presenter.error
@@ -55,6 +59,10 @@ class PartYearProfitTaxCreditsViewTest < ActiveSupport::TestCase
5559
@presenter = QuestionPresenter.new(@i18n_prefix, question, @state)
5660
end
5761

62+
should 'have options with labels' do
63+
assert_equal({ 'yes' => 'Yes', 'no' => 'No' }, values_vs_labels(@presenter.options))
64+
end
65+
5866
should 'have a default error message' do
5967
@state.error = 'error-message'
6068
assert_equal 'You need to select yes or no to continue.', @presenter.error
@@ -74,6 +82,10 @@ class PartYearProfitTaxCreditsViewTest < ActiveSupport::TestCase
7482
assert_equal expected, @presenter.title
7583
end
7684

85+
should 'have options with labels' do
86+
assert_equal({ 'yes' => 'Yes', 'no' => 'No' }, values_vs_labels(@presenter.options))
87+
end
88+
7789
should 'have a default error message' do
7890
@state.error = 'error-message'
7991
assert_equal 'You need to select yes or no to continue.', @presenter.error
@@ -219,5 +231,11 @@ class PartYearProfitTaxCreditsViewTest < ActiveSupport::TestCase
219231
end
220232
end
221233
end
234+
235+
private
236+
237+
def values_vs_labels(options)
238+
options.inject({}) { |h,o| h[o.value] = o.label; h }
239+
end
222240
end
223241
end

0 commit comments

Comments
 (0)