diff --git a/app/components/layout/notification_item_component.html.erb b/app/components/layout/notification_item_component.html.erb
index 8be3090d3..3b96d2454 100644
--- a/app/components/layout/notification_item_component.html.erb
+++ b/app/components/layout/notification_item_component.html.erb
@@ -1,12 +1,10 @@
-<% if user %>
-
- <%= link_to notifications_path, rel: "nofollow",
- title: text,
- class: "notifications #{notifications_class}" do %>
-
- <%= t("layouts.header.notification_item.notifications") %>
-
- <%= text %>
- <% end %>
-
-<% end %>
+
+ <%= link_to notifications_path, rel: "nofollow",
+ title: text,
+ class: "notifications #{notifications_class}" do %>
+
+ <%= t("layouts.header.notification_item.notifications") %>
+
+ <%= text %>
+ <% end %>
+
diff --git a/app/components/layout/notification_item_component.rb b/app/components/layout/notification_item_component.rb
index c620180b0..5a767e418 100644
--- a/app/components/layout/notification_item_component.rb
+++ b/app/components/layout/notification_item_component.rb
@@ -5,6 +5,10 @@ class Layout::NotificationItemComponent < ApplicationComponent
@user = user
end
+ def render?
+ user.present?
+ end
+
private
def text
diff --git a/spec/components/layout/notification_item_component_spec.rb b/spec/components/layout/notification_item_component_spec.rb
new file mode 100644
index 000000000..086ee817a
--- /dev/null
+++ b/spec/components/layout/notification_item_component_spec.rb
@@ -0,0 +1,15 @@
+require "rails_helper"
+
+describe Layout::NotificationItemComponent do
+ it "is not rendered for anonymous users" do
+ render_inline Layout::NotificationItemComponent.new(nil)
+
+ expect(page).not_to be_rendered
+ end
+
+ it "is rendered for identified users" do
+ render_inline Layout::NotificationItemComponent.new(create(:user))
+
+ expect(page).to be_rendered
+ end
+end