Simplify notification item HTML

Other than simplifying the view, we can write tests using `click_link`,
which makes the tests more robust. Clicking the `.icon-notification`
element was causing some tests to fail when defining a window height of
750 pixels in the `admin_budgets` branch.
This commit is contained in:
Javi Martín
2021-02-16 00:30:01 +01:00
parent 5b6551f6d7
commit 4c289f2489
8 changed files with 72 additions and 51 deletions

View File

@@ -8,10 +8,22 @@ class Layout::NotificationItemComponent < ApplicationComponent
private
def text
if user.notifications.unread.count > 0
if unread_notifications?
t("layouts.header.notification_item.new_notifications", count: user.notifications_count)
else
t("layouts.header.notification_item.no_notifications")
end
end
def notifications_class
if unread_notifications?
"unread-notifications"
else
"no-notifications"
end
end
def unread_notifications?
user.notifications.unread.count > 0
end
end