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.
30 lines
607 B
Ruby
30 lines
607 B
Ruby
class Layout::NotificationItemComponent < ApplicationComponent
|
|
attr_reader :user
|
|
|
|
def initialize(user)
|
|
@user = user
|
|
end
|
|
|
|
private
|
|
|
|
def text
|
|
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
|