Add render method to notification item component
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
<% if user %>
|
<li id="notifications">
|
||||||
<li id="notifications">
|
|
||||||
<%= link_to notifications_path, rel: "nofollow",
|
<%= link_to notifications_path, rel: "nofollow",
|
||||||
title: text,
|
title: text,
|
||||||
class: "notifications #{notifications_class}" do %>
|
class: "notifications #{notifications_class}" do %>
|
||||||
@@ -8,5 +7,4 @@
|
|||||||
</span>
|
</span>
|
||||||
<span class="show-for-small-only"><%= text %></span>
|
<span class="show-for-small-only"><%= text %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ class Layout::NotificationItemComponent < ApplicationComponent
|
|||||||
@user = user
|
@user = user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render?
|
||||||
|
user.present?
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def text
|
def text
|
||||||
|
|||||||
15
spec/components/layout/notification_item_component_spec.rb
Normal file
15
spec/components/layout/notification_item_component_spec.rb
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user