From 35354565194715218f15c32a328e1834f8c7316d Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Thu, 11 Jan 2024 10:10:30 +0000 Subject: [PATCH] feat: move notification helper methods to notifications_helper.rb --- app/helpers/application_helper.rb | 16 ---------------- app/helpers/notifications_helper.rb | 17 +++++++++++++++++ app/views/layouts/application.html.erb | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 app/helpers/notifications_helper.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6fff94f5e..01f7734c2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -31,22 +31,6 @@ module ApplicationHelper !current_page?(notifications_path) && (authenticated_user_has_notifications? || unauthenticated_user_has_notifications?) end - def notification_count - if current_user.present? - current_user.active_unread_notifications.count - else - Notification.active_unauthenticated_notifications.count - end - end - - def notification - if current_user.present? - current_user.newest_active_unread_notification - else - Notification.newest_active_unauthenticated_notification - end - end - private def paginated_title(title, pagy) diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb new file mode 100644 index 000000000..ab4c8ec21 --- /dev/null +++ b/app/helpers/notifications_helper.rb @@ -0,0 +1,17 @@ +module NotificationsHelper + def notification_count + if current_user.present? + current_user.active_unread_notifications.count + else + Notification.active_unauthenticated_notifications.count + end + end + + def notification + if current_user.present? + current_user.newest_active_unread_notification + else + Notification.newest_active_unauthenticated_notification + end + end +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 3a6924ae2..1ed5014c3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -100,7 +100,7 @@ end %> <% if notifications_to_display? %> - <%= render "notifications/notification_banner", notification_count:, notification: %> + <%= render "notifications/notification_banner" %> <% end %> <% feedback_link = govuk_link_to "giving us your feedback (opens in a new tab)", t("feedback_form"), rel: "noreferrer noopener", target: "_blank" %>