From 46bf83df8482a6838cc23bdaca139b696040ca62 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Mon, 9 May 2022 13:53:42 +0100 Subject: [PATCH] Fix specs and linters --- app/components/primary_navigation_component.rb | 4 ++++ app/views/layouts/application.html.erb | 2 +- spec/components/primary_navigation_component_spec.rb | 8 +++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/components/primary_navigation_component.rb b/app/components/primary_navigation_component.rb index 33f5a9529..f9668f812 100644 --- a/app/components/primary_navigation_component.rb +++ b/app/components/primary_navigation_component.rb @@ -5,4 +5,8 @@ class PrimaryNavigationComponent < ViewComponent::Base @items = items super end + + def highlighted_tab?(item, _path) + item[:current] + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index cefeea24b..335cc0ff3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -66,7 +66,7 @@ <% if !current_user.nil? %> <%= render PrimaryNavigationComponent.new( - items: primary_items(current_user) + items: primary_items(current_user), ) %> <% end %> diff --git a/spec/components/primary_navigation_component_spec.rb b/spec/components/primary_navigation_component_spec.rb index 999dbfaf5..46f45166d 100644 --- a/spec/components/primary_navigation_component_spec.rb +++ b/spec/components/primary_navigation_component_spec.rb @@ -2,9 +2,11 @@ require "rails_helper" RSpec.describe PrimaryNavigationComponent, type: :component do let(:items) do - [{ text: "Organisations", href: "/organisations", current: true }, - { text: "Users", href: "/users", current: false }, - { text: "Logs ", href: "/logs", current: false }] + [ + NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true), + NavigationItemsHelper::NavigationItem.new("Users", "/users", false), + NavigationItemsHelper::NavigationItem.new("Logs ", "/logs", false), + ] end context "when the item is 'current' in nav tabs" do