From 84d8d6ee95e98693568318145f4d5ad64713ba0f Mon Sep 17 00:00:00 2001 From: Matthew Phelan Date: Mon, 6 Dec 2021 11:56:15 +0000 Subject: [PATCH] Error prefix code review changes --- app/helpers/application_helper.rb | 18 +++++++++++++++++- app/views/layouts/application.html.erb | 10 +--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9ad342b8a..af51a93e7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,5 +1,21 @@ module ApplicationHelper def browser_title(title) - [title, t("service_name"), "GOV.UK"].select(&:present?).join(" - ") + if user_log_errors || case_log_errors || resource_errors + ["Error", title, t("service_name"), "GOV.UK"].select(&:present?).join(" - ") + else + [title, t("service_name"), "GOV.UK"].select(&:present?).join(" - ") + end + end + + def user_log_errors + @user.present? && @user.errors.present? + end + + def case_log_errors + @case_log.present? && @case_log.errors.present? + end + + def resource_errors + @resource.present? && @resource.errors.present? end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2a0a0bec3..3273c8ca3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,15 +1,7 @@ - <% if @resource.present? && @resource.errors.present? %> - <%= browser_title("Error: #{yield(:title)}") %> - <% elsif @user.present? && @user.errors.present? %> - <%= browser_title("Error: #{yield(:title)}") %> - <% elsif @case_log.present? && @case_log.errors.present?%> - <%= browser_title("Error: #{yield(:title)}") %> - <% else %> - <%= browser_title(yield(:title)) %> - <% end %> + <%= browser_title(yield(:title)) %> <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= tag :meta, name: 'viewport', content: 'width=device-width, initial-scale=1' %>