From 16d63aff7e41962c953b38da457bb145f462824b Mon Sep 17 00:00:00 2001 From: Samuel Oey Date: Tue, 6 Aug 2024 18:31:08 +0200 Subject: [PATCH] feat: prepare navbar for route changes by adding the organization parameter --- app/components/nav_bar/nav_bar.rb | 5 +++-- app/views/layouts/application.html.erb | 2 +- spec/components/nav_bar_spec.rb | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/components/nav_bar/nav_bar.rb b/app/components/nav_bar/nav_bar.rb index 756e5da7f..fe90f58ae 100644 --- a/app/components/nav_bar/nav_bar.rb +++ b/app/components/nav_bar/nav_bar.rb @@ -2,14 +2,15 @@ module NavBar class NavBar < ApplicationComponent - def initialize(current_user:, **) + def initialize(organization:, current_user:, **) super + @organization = organization @current_user = current_user end private - attr_reader :current_user + attr_reader :current_user, :organization end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index d48dab203..4d4867e82 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -17,7 +17,7 @@
- <%= c 'nav_bar', current_user: current_user %> + <%= c 'nav_bar', organization: @organization, current_user: current_user %> <%= c 'browser_support_notification' %> <%= c 'notifications', notifications: flash, style: :floating, close_after: 6000 %> <%= yield :notifications %> diff --git a/spec/components/nav_bar_spec.rb b/spec/components/nav_bar_spec.rb index e0c478e1a..8d2936efa 100644 --- a/spec/components/nav_bar_spec.rb +++ b/spec/components/nav_bar_spec.rb @@ -5,6 +5,7 @@ RSpec.describe NavBar::NavBar, type: :component do subject { render_inline(described_class.new(**params)) } - let(:params) { { current_user: create(:user) } } + let(:organization) { create(:organization) } + let(:params) { { organization: organization, current_user: create(:user) } } it { should have_css('.NavBar') } end