From db4c82e2eccf5a4ee150315e64589c3b58695b52 Mon Sep 17 00:00:00 2001 From: James Mead Date: Thu, 19 Nov 2015 15:19:55 +0000 Subject: [PATCH 1/4] Use ERB templates for Qs in state-pension-topup I ran the following command: $ rails r script/convert-question-i18-yaml-to-erb-templates.rb lib/smart_answer_flows/state-pension-topup Writing template: dob_age.govspeak.erb Writing template: date_of_lump_sum_payment.govspeak.erb Writing template: how_much_extra_per_week.govspeak.erb Writing template: gender.govspeak.erb Deleting i18n YAML: state-pension-topup.yml Now insert `use_erb_templates_for_questions` at top of flow: state-pension-topup.rb --- .../locales/en/state-pension-topup.yml | 23 ------------------- .../date_of_lump_sum_payment.govspeak.erb | 11 +++++++++ .../questions/dob_age.govspeak.erb | 7 ++++++ .../questions/gender.govspeak.erb | 8 +++++++ .../how_much_extra_per_week.govspeak.erb | 11 +++++++++ 5 files changed, 37 insertions(+), 23 deletions(-) delete mode 100644 lib/smart_answer_flows/locales/en/state-pension-topup.yml create mode 100644 lib/smart_answer_flows/state-pension-topup/questions/date_of_lump_sum_payment.govspeak.erb create mode 100644 lib/smart_answer_flows/state-pension-topup/questions/dob_age.govspeak.erb create mode 100644 lib/smart_answer_flows/state-pension-topup/questions/gender.govspeak.erb create mode 100644 lib/smart_answer_flows/state-pension-topup/questions/how_much_extra_per_week.govspeak.erb diff --git a/lib/smart_answer_flows/locales/en/state-pension-topup.yml b/lib/smart_answer_flows/locales/en/state-pension-topup.yml deleted file mode 100644 index fa81776315c..00000000000 --- a/lib/smart_answer_flows/locales/en/state-pension-topup.yml +++ /dev/null @@ -1,23 +0,0 @@ -en-GB: - flow: - state-pension-topup: -#Q1 - dob_age?: - title: What is your date of birth? - error_message: Enter your date of birth. -#Q2 - date_of_lump_sum_payment?: - title: When will you pay your lump sum? - hint: This must be between 12 October 2015 and 5 April 2017. - error_message: Enter a date between 12 October 2015 and 5 April 2017. -#Q3 - how_much_extra_per_week?: - title: How much extra State Pension would you like to get per week? - hint: Enter a number between 1 and 25. - error_message: Enter an amount in whole pounds between 1 and 25. -#Q4 - gender?: - title: What is your gender? - options: - "male": "Male" - "female": "Female" diff --git a/lib/smart_answer_flows/state-pension-topup/questions/date_of_lump_sum_payment.govspeak.erb b/lib/smart_answer_flows/state-pension-topup/questions/date_of_lump_sum_payment.govspeak.erb new file mode 100644 index 00000000000..4f6d274e045 --- /dev/null +++ b/lib/smart_answer_flows/state-pension-topup/questions/date_of_lump_sum_payment.govspeak.erb @@ -0,0 +1,11 @@ +<% content_for :title do %> + When will you pay your lump sum? +<% end %> + +<% content_for :hint do %> + This must be between 12 October 2015 and 5 April 2017. +<% end %> + +<% content_for :error_message do %> + Enter a date between 12 October 2015 and 5 April 2017. +<% end %> diff --git a/lib/smart_answer_flows/state-pension-topup/questions/dob_age.govspeak.erb b/lib/smart_answer_flows/state-pension-topup/questions/dob_age.govspeak.erb new file mode 100644 index 00000000000..4d2876e70db --- /dev/null +++ b/lib/smart_answer_flows/state-pension-topup/questions/dob_age.govspeak.erb @@ -0,0 +1,7 @@ +<% content_for :title do %> + What is your date of birth? +<% end %> + +<% content_for :error_message do %> + Enter your date of birth. +<% end %> diff --git a/lib/smart_answer_flows/state-pension-topup/questions/gender.govspeak.erb b/lib/smart_answer_flows/state-pension-topup/questions/gender.govspeak.erb new file mode 100644 index 00000000000..4ea7e552f26 --- /dev/null +++ b/lib/smart_answer_flows/state-pension-topup/questions/gender.govspeak.erb @@ -0,0 +1,8 @@ +<% content_for :title do %> + What is your gender? +<% end %> + +<% options( + "male": "Male", + "female": "Female" +) %> diff --git a/lib/smart_answer_flows/state-pension-topup/questions/how_much_extra_per_week.govspeak.erb b/lib/smart_answer_flows/state-pension-topup/questions/how_much_extra_per_week.govspeak.erb new file mode 100644 index 00000000000..cf3fb997003 --- /dev/null +++ b/lib/smart_answer_flows/state-pension-topup/questions/how_much_extra_per_week.govspeak.erb @@ -0,0 +1,11 @@ +<% content_for :title do %> + How much extra State Pension would you like to get per week? +<% end %> + +<% content_for :hint do %> + Enter a number between 1 and 25. +<% end %> + +<% content_for :error_message do %> + Enter an amount in whole pounds between 1 and 25. +<% end %> From 315270349903a6d7d9438b589255daf445c1ad43 Mon Sep 17 00:00:00 2001 From: James Mead Date: Thu, 19 Nov 2015 15:20:46 +0000 Subject: [PATCH 2/4] Now insert use_erb_templates_for_questions at top of flow --- lib/smart_answer_flows/state-pension-topup.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/smart_answer_flows/state-pension-topup.rb b/lib/smart_answer_flows/state-pension-topup.rb index 2bc29038265..39cb1a2838d 100644 --- a/lib/smart_answer_flows/state-pension-topup.rb +++ b/lib/smart_answer_flows/state-pension-topup.rb @@ -6,6 +6,8 @@ def define status :published satisfies_need "100865" + use_erb_templates_for_questions + calculator = Calculators::StatePensionTopupCalculator.new #Q1 From 607f2fb63d9681e77203b085e5084d35b3eff651 Mon Sep 17 00:00:00 2001 From: James Mead Date: Thu, 19 Nov 2015 15:21:25 +0000 Subject: [PATCH 3/4] Update regression test artefacts The change to ERB templates has introduced a few extra newlines in the question page HTML, but none of them affect the content viewable by the user. I verified that the changes were all only blank lines using the following command: $ git diff --ignore-blank-lines --- test/artefacts/state-pension-topup/1912-10-12.html | 2 ++ test/artefacts/state-pension-topup/1912-10-12/male.html | 2 ++ test/artefacts/state-pension-topup/y.html | 2 ++ 3 files changed, 6 insertions(+) diff --git a/test/artefacts/state-pension-topup/1912-10-12.html b/test/artefacts/state-pension-topup/1912-10-12.html index 8b5f5fe785b..8d4faf4b256 100644 --- a/test/artefacts/state-pension-topup/1912-10-12.html +++ b/test/artefacts/state-pension-topup/1912-10-12.html @@ -38,6 +38,7 @@

+
    @@ -57,6 +58,7 @@

    +

diff --git a/test/artefacts/state-pension-topup/1912-10-12/male.html b/test/artefacts/state-pension-topup/1912-10-12/male.html index d67c4f44d0d..056cac55e1b 100644 --- a/test/artefacts/state-pension-topup/1912-10-12/male.html +++ b/test/artefacts/state-pension-topup/1912-10-12/male.html @@ -37,6 +37,7 @@

+

Enter a number between 1 and 25.

@@ -45,6 +46,7 @@

+

diff --git a/test/artefacts/state-pension-topup/y.html b/test/artefacts/state-pension-topup/y.html index 792ba935aa0..d234bbeb48a 100644 --- a/test/artefacts/state-pension-topup/y.html +++ b/test/artefacts/state-pension-topup/y.html @@ -38,6 +38,7 @@

+
@@ -229,6 +230,7 @@

+

From 0d1a5f8a4337a59b107304799c084d2c2bb454d5 Mon Sep 17 00:00:00 2001 From: James Mead Date: Thu, 19 Nov 2015 15:21:42 +0000 Subject: [PATCH 4/4] Update regression test checksums Re-generating the checksums has removed the i18n YAML file and added the new question templates as I expected. --- test/data/state-pension-topup-files.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/data/state-pension-topup-files.yml b/test/data/state-pension-topup-files.yml index 4534036c5b4..c8e3c8daf7c 100644 --- a/test/data/state-pension-topup-files.yml +++ b/test/data/state-pension-topup-files.yml @@ -1,10 +1,13 @@ --- -lib/smart_answer_flows/state-pension-topup.rb: 588abd953a7a80e1ead751394e72ab0c -lib/smart_answer_flows/locales/en/state-pension-topup.yml: 723be2cd9151b43de550a4972b36f862 +lib/smart_answer_flows/state-pension-topup.rb: add9d1e0c664800bc64755277b6d0670 test/data/state-pension-topup-questions-and-responses.yml: f4f609a6e989f166616a05435c6993aa test/data/state-pension-topup-responses-and-expected-results.yml: 1207c6118839a3b13810038c57a20d4a lib/smart_answer_flows/state-pension-topup/outcomes/outcome_pension_age_not_reached.govspeak.erb: 558d49584fe1ece4d36427740d381273 lib/smart_answer_flows/state-pension-topup/outcomes/outcome_topup_calculations.govspeak.erb: 421d026a06ca1c7dcb56e2712189211a +lib/smart_answer_flows/state-pension-topup/questions/date_of_lump_sum_payment.govspeak.erb: bc785eb5fa3ee27edfaf9f223694942b +lib/smart_answer_flows/state-pension-topup/questions/dob_age.govspeak.erb: a98e10bf8b60c21f65d307a56046f4d3 +lib/smart_answer_flows/state-pension-topup/questions/gender.govspeak.erb: f388163b3d7abb9c78bfe8265b2f2856 +lib/smart_answer_flows/state-pension-topup/questions/how_much_extra_per_week.govspeak.erb: fcbf62d8db40dde727445b1742e7b958 lib/smart_answer_flows/state-pension-topup/state_pension_topup.govspeak.erb: 519a1c6174840e90d2ce509aff91d7be lib/smart_answer/calculators/state_pension_topup_calculator.rb: f03d5ababde67182513daf834b85a1db lib/smart_answer/calculators/state_pension_topup_data_query.rb: d18c0d8df71ac858809f11a0b5fb0e63