From 889d8eb3fcb5acdf0fe6d40269550eeafd3995dc Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Wed, 8 Jan 2025 14:11:39 +0000 Subject: [PATCH] Standardise admin dates We want to present all dates in the admin area in the "%-d %B %Y" format, which is the default in the locales file. --- app/helpers/admin/claims_helper.rb | 2 +- app/helpers/admin/timeline_helper.rb | 2 +- .../admin_claim_details_presenter.rb | 2 +- .../early_years_payments/admin_tasks_presenter.rb | 8 ++++++-- app/views/admin/tasks/_claim_summary.html.erb | 2 +- .../_claim_summary_early_years_payments.html.erb | 2 +- ...claim_summary_further_education_payments.html.erb | 2 +- ...ummary_international_relocation_payments.html.erb | 2 +- spec/features/admin/admin_amend_claim_spec.rb | 2 +- spec/features/admin/admin_ey_tasks_spec.rb | 12 ++++++------ .../admin_view_claim_early_years_payments_spec.rb | 2 +- ...dmin_view_full_claim_early_years_payments_spec.rb | 2 +- ...iew_full_claim_further_education_payments_spec.rb | 2 +- spec/helpers/admin/claims_helper_spec.rb | 2 +- spec/helpers/admin/timeline_helper_spec.rb | 2 +- .../admin_claim_details_presenter_spec.rb | 2 +- .../admin_tasks_presenter_spec.rb | 4 ++-- 17 files changed, 28 insertions(+), 24 deletions(-) diff --git a/app/helpers/admin/claims_helper.rb b/app/helpers/admin/claims_helper.rb index 8343a4f287..b9a1db6613 100644 --- a/app/helpers/admin/claims_helper.rb +++ b/app/helpers/admin/claims_helper.rb @@ -38,7 +38,7 @@ def admin_personal_details(claim) [ [translate("admin.teacher_reference_number"), claim.eligibility.teacher_reference_number.presence || "Not provided"], [translate("#{claim.policy.locale_key}.govuk_verify_fields.full_name", default: :"govuk_verify_fields.full_name").capitalize, claim.personal_data_removed? ? personal_data_removed_text : claim.full_name], - [translate("govuk_verify_fields.date_of_birth").capitalize, claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :day_month_year)], + [translate("govuk_verify_fields.date_of_birth").capitalize, claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth)], [translate("admin.national_insurance_number"), claim.personal_data_removed? ? personal_data_removed_text : claim.national_insurance_number], [translate("govuk_verify_fields.address").capitalize, claim.personal_data_removed? ? personal_data_removed_text : sanitize(claim.address("
").html_safe, tags: %w[br])], [translate("#{claim.policy.locale_key}.admin.email_address", default: :"admin.email_address"), claim.email_address] diff --git a/app/helpers/admin/timeline_helper.rb b/app/helpers/admin/timeline_helper.rb index b2f86862b6..b8d0c377c3 100644 --- a/app/helpers/admin/timeline_helper.rb +++ b/app/helpers/admin/timeline_helper.rb @@ -32,7 +32,7 @@ def admin_amendment_attribute_name(attribute) def admin_amendment_format_attribute(attribute, value) override = case attribute.to_s when "payroll_gender" then "don’t know" if value.to_s == "dont_know" - when "date_of_birth" then l(value, format: :day_month_year) + when "date_of_birth" then l(value) when "student_loan_repayment_amount" then number_to_currency(value) when "student_loan_plan" then (value.to_s == "not_applicable") ? "not applicable" : value&.humanize when "award_amount" then number_to_currency(value) diff --git a/app/models/policies/early_years_payments/admin_claim_details_presenter.rb b/app/models/policies/early_years_payments/admin_claim_details_presenter.rb index 72637f170b..270d474e70 100644 --- a/app/models/policies/early_years_payments/admin_claim_details_presenter.rb +++ b/app/models/policies/early_years_payments/admin_claim_details_presenter.rb @@ -16,7 +16,7 @@ def initialize(claim) def personal_details [ [translate("#{claim.policy.locale_key}.govuk_verify_fields.full_name").capitalize, personal_data(claim.full_name)], - [translate("govuk_verify_fields.date_of_birth").capitalize, personal_data(formatted_date(claim.date_of_birth, format: :day_month_year))], + [translate("govuk_verify_fields.date_of_birth").capitalize, personal_data(formatted_date(claim.date_of_birth))], [translate("admin.national_insurance_number"), personal_data(claim.national_insurance_number)], [translate("govuk_verify_fields.address").capitalize, personal_data(sanitize(claim.address("
").html_safe, tags: %w[br]))], [translate("#{claim.policy.locale_key}.admin.email_address"), claim.email_address], diff --git a/app/models/policies/early_years_payments/admin_tasks_presenter.rb b/app/models/policies/early_years_payments/admin_tasks_presenter.rb index 68fe8256e8..c7483052b6 100644 --- a/app/models/policies/early_years_payments/admin_tasks_presenter.rb +++ b/app/models/policies/early_years_payments/admin_tasks_presenter.rb @@ -25,7 +25,9 @@ def provider_entered_claimant_name end def practitioner_entered_dob - claim.date_of_birth + return unless claim.date_of_birth + + I18n.l(claim.date_of_birth) end def one_login_claimant_name @@ -33,7 +35,9 @@ def one_login_claimant_name end def one_login_claimant_dob - claim.onelogin_idv_date_of_birth + return unless claim.onelogin_idv_date_of_birth + + I18n.l(claim.onelogin_idv_date_of_birth) end def practitioner_journey_completed? diff --git a/app/views/admin/tasks/_claim_summary.html.erb b/app/views/admin/tasks/_claim_summary.html.erb index f99af0d224..5dea93bdc8 100644 --- a/app/views/admin/tasks/_claim_summary.html.erb +++ b/app/views/admin/tasks/_claim_summary.html.erb @@ -54,7 +54,7 @@
- <%= claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :day_month_year) %> + <%= claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth) %>
diff --git a/app/views/admin/tasks/_claim_summary_early_years_payments.html.erb b/app/views/admin/tasks/_claim_summary_early_years_payments.html.erb index 051659fd09..63a524cc07 100644 --- a/app/views/admin/tasks/_claim_summary_early_years_payments.html.erb +++ b/app/views/admin/tasks/_claim_summary_early_years_payments.html.erb @@ -72,7 +72,7 @@
<% if claim.date_of_birth.present? %> - <%= claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :day_month_year) %> + <%= claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth) %> <% end %>
diff --git a/app/views/admin/tasks/_claim_summary_further_education_payments.html.erb b/app/views/admin/tasks/_claim_summary_further_education_payments.html.erb index 4f88ba0ad7..a87f0aa023 100644 --- a/app/views/admin/tasks/_claim_summary_further_education_payments.html.erb +++ b/app/views/admin/tasks/_claim_summary_further_education_payments.html.erb @@ -53,7 +53,7 @@
- <%= claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :day_month_year) %> + <%= claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth) %>
diff --git a/app/views/admin/tasks/_claim_summary_international_relocation_payments.html.erb b/app/views/admin/tasks/_claim_summary_international_relocation_payments.html.erb index b5b1f6ee51..1964656197 100644 --- a/app/views/admin/tasks/_claim_summary_international_relocation_payments.html.erb +++ b/app/views/admin/tasks/_claim_summary_international_relocation_payments.html.erb @@ -39,7 +39,7 @@ <% summary_list.with_row do |row| %> <% row.with_key { "Date of birth" } %> - <% row.with_value { claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :day_month_year) } %> + <% row.with_value { claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth) } %> <% end %> <% summary_list.with_row do |row| %> diff --git a/spec/features/admin/admin_amend_claim_spec.rb b/spec/features/admin/admin_amend_claim_spec.rb index ff89ec279f..fe0408beca 100644 --- a/spec/features/admin/admin_amend_claim_spec.rb +++ b/spec/features/admin/admin_amend_claim_spec.rb @@ -92,7 +92,7 @@ click_on "Claim amendments" expect(page).to have_content("Teacher reference number\nchanged from 1234567 to 7654321") - expect(page).to have_content("Date of birth\nchanged from #{I18n.l(date_of_birth, format: :day_month_year)} to #{I18n.l(new_date_of_birth, format: :day_month_year)}") + expect(page).to have_content("Date of birth\nchanged from #{I18n.l(date_of_birth)} to #{I18n.l(new_date_of_birth)}") expect(page).to have_content("Student loan repayment plan\nchanged from Plan 1 to Plan 2") expect(page).to have_content("Bank sort code\nchanged from 010203 to 111213") expect(page).to have_content("Bank account number\nchanged from 47274828 to 18929492") diff --git a/spec/features/admin/admin_ey_tasks_spec.rb b/spec/features/admin/admin_ey_tasks_spec.rb index 3cb1241792..57d2b04270 100644 --- a/spec/features/admin/admin_ey_tasks_spec.rb +++ b/spec/features/admin/admin_ey_tasks_spec.rb @@ -52,11 +52,11 @@ click_on "Confirm the claimant made the claim" expect(page).to have_content( - "Provider entered claimant name Bobby Bobberson 1986-01-01" + "Provider entered claimant name Bobby Bobberson 1 January 1986" ) expect(page).to have_content( - "One Login identity verification (IDV) Bobby Bobberson 1986-01-01" + "One Login identity verification (IDV) Bobby Bobberson 1 January 1986" ) expect(page).to have_content( @@ -90,11 +90,11 @@ click_on "Confirm the claimant made the claim" expect(page).to have_content( - "Provider entered claimant name Bobby Bobberson 1986-01-01" + "Provider entered claimant name Bobby Bobberson 1 January 1986" ) expect(page).to have_content( - "One Login identity verification (IDV) Robby Bobberson 1986-01-01" + "One Login identity verification (IDV) Robby Bobberson 1 January 1986" ) expect(page).to have_content( @@ -166,11 +166,11 @@ click_on "Confirm the claimant made the claim" expect(page).to have_content( - "Provider entered claimant name Bobby Bobberson 1986-01-01" + "Provider entered claimant name Bobby Bobberson 1 January 1986" ) expect(page).to have_content( - "One Login identity verification (IDV) Robby Robberson 1986-01-01" + "One Login identity verification (IDV) Robby Robberson 1 January 1986" ) expect(page).to have_content( diff --git a/spec/features/admin/admin_view_claim_early_years_payments_spec.rb b/spec/features/admin/admin_view_claim_early_years_payments_spec.rb index a5c9e23733..8141cc1723 100644 --- a/spec/features/admin/admin_view_claim_early_years_payments_spec.rb +++ b/spec/features/admin/admin_view_claim_early_years_payments_spec.rb @@ -50,7 +50,7 @@ expect(page).to have_summary_item(key: "Contact email", value: practitioner_claim.email_address) expect(page).to have_summary_item(key: "Provider email", value: practitioner_claim.eligibility.provider_email_address) expect(page).to have_summary_item(key: "Start date", value: practitioner_claim.eligibility.start_date.strftime(I18n.t("date.formats.default"))) - expect(page).to have_summary_item(key: "Date of birth", value: practitioner_claim.date_of_birth.strftime(I18n.t("date.formats.day_month_year"))) + expect(page).to have_summary_item(key: "Date of birth", value: practitioner_claim.date_of_birth.strftime(I18n.t("date.formats.default"))) expect(page).to have_summary_item(key: "Mobile number", value: practitioner_claim.mobile_number) expect(page).to have_summary_item(key: "Reference", value: practitioner_claim.reference) expect(page).to have_summary_item(key: "Submitted", value: practitioner_claim.submitted_at.strftime(I18n.t("time.formats.default"))) diff --git a/spec/features/admin/admin_view_full_claim_early_years_payments_spec.rb b/spec/features/admin/admin_view_full_claim_early_years_payments_spec.rb index f6d516850a..8698f931f9 100644 --- a/spec/features/admin/admin_view_full_claim_early_years_payments_spec.rb +++ b/spec/features/admin/admin_view_full_claim_early_years_payments_spec.rb @@ -102,7 +102,7 @@ it "shows the claim details" do expect(summary_row("Applicant name")).to have_content("Bruce Wayne") - expect(summary_row("Date of birth")).to have_content("01/01/1901") + expect(summary_row("Date of birth")).to have_content("1 January 1901") expect(summary_row("National Insurance number")).to have_content("QQ123456C") expect(summary_row("Address")).to have_content("Flat 1") expect(summary_row("Address")).to have_content("1 Test Road") diff --git a/spec/features/admin/admin_view_full_claim_further_education_payments_spec.rb b/spec/features/admin/admin_view_full_claim_further_education_payments_spec.rb index f3bcbde01f..36a6969f92 100644 --- a/spec/features/admin/admin_view_full_claim_further_education_payments_spec.rb +++ b/spec/features/admin/admin_view_full_claim_further_education_payments_spec.rb @@ -62,7 +62,7 @@ expect(summary_row("Full name")).to have_content("Edna Krabappel") - expect(summary_row("Date of birth")).to have_content("03/07/1945") + expect(summary_row("Date of birth")).to have_content("3 July 1945") expect(summary_row("National Insurance number")).to have_content( "QQ123456C" diff --git a/spec/helpers/admin/claims_helper_spec.rb b/spec/helpers/admin/claims_helper_spec.rb index 2babca4a55..93c8f37d66 100644 --- a/spec/helpers/admin/claims_helper_spec.rb +++ b/spec/helpers/admin/claims_helper_spec.rb @@ -25,7 +25,7 @@ expected_answers = [ [I18n.t("admin.teacher_reference_number"), "1234567"], [I18n.t("govuk_verify_fields.full_name").capitalize, "Bruce Wayne"], - [I18n.t("govuk_verify_fields.date_of_birth").capitalize, "01/01/1901"], + [I18n.t("govuk_verify_fields.date_of_birth").capitalize, "1 January 1901"], [I18n.t("admin.national_insurance_number"), "QQ123456C"], [I18n.t("govuk_verify_fields.address").capitalize, "Flat 1
1 Test Road
Test Town
AB1 2CD"], [I18n.t("admin.email_address"), "test@email.com"] diff --git a/spec/helpers/admin/timeline_helper_spec.rb b/spec/helpers/admin/timeline_helper_spec.rb index 3b76d7a36f..681ab45156 100644 --- a/spec/helpers/admin/timeline_helper_spec.rb +++ b/spec/helpers/admin/timeline_helper_spec.rb @@ -19,7 +19,7 @@ expect(helper.admin_amendment_details(amendment)).to eq([ ["Bank account number", "12345678", "87654321"], ["Bank sort code", "123456", "654321"], - ["Date of birth", "25/02/1995", "25/02/1990"], + ["Date of birth", "25 February 1995", "25 February 1990"], ["Payroll gender", "male", "don’t know"], ["Student loan repayment amount", "£123.00", "£456.00"], ["Student loan repayment plan", "not applicable", "Plan 1"], diff --git a/spec/models/policies/early_years_payments/admin_claim_details_presenter_spec.rb b/spec/models/policies/early_years_payments/admin_claim_details_presenter_spec.rb index d41f8b522a..a07d5ebc7b 100644 --- a/spec/models/policies/early_years_payments/admin_claim_details_presenter_spec.rb +++ b/spec/models/policies/early_years_payments/admin_claim_details_presenter_spec.rb @@ -91,7 +91,7 @@ it "returns an array of questions and answers" do expected_answers = [ [I18n.t("early_years_payments.govuk_verify_fields.full_name").capitalize, "Bruce Wayne"], - [I18n.t("govuk_verify_fields.date_of_birth").capitalize, "01/01/1901"], + [I18n.t("govuk_verify_fields.date_of_birth").capitalize, "1 January 1901"], [I18n.t("admin.national_insurance_number"), "QQ123456C"], [I18n.t("govuk_verify_fields.address").capitalize, "Flat 1
1 Test Road
Test Town
AB1 2CD"], [I18n.t("early_years_payments.admin.email_address"), "test@example.com"], diff --git a/spec/models/policies/early_years_payments/admin_tasks_presenter_spec.rb b/spec/models/policies/early_years_payments/admin_tasks_presenter_spec.rb index 61cd410292..c10233a39e 100644 --- a/spec/models/policies/early_years_payments/admin_tasks_presenter_spec.rb +++ b/spec/models/policies/early_years_payments/admin_tasks_presenter_spec.rb @@ -48,7 +48,7 @@ subject { described_class.new(claim).practitioner_entered_dob } - it { is_expected.to eq Date.new(1990, 1, 1) } + it { is_expected.to eq I18n.l(Date.new(1990, 1, 1)) } end describe "#one_login_claimant_dob" do @@ -63,6 +63,6 @@ subject { described_class.new(claim).one_login_claimant_dob } - it { is_expected.to eq Date.new(1990, 2, 1) } + it { is_expected.to eq I18n.l(Date.new(1990, 2, 1)) } end end