From 1983aa1940acc6371ae2b79ad5befd4110754215 Mon Sep 17 00:00:00 2001 From: Paul Robert Lloyd Date: Wed, 1 Dec 2021 18:54:51 +0000 Subject: [PATCH] Show correct links in header nav when signed in/out --- app/views/layouts/application.html.erb | 5 +++-- spec/features/user_spec.rb | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 19af05162..6a1a25962 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -37,10 +37,11 @@ service_url: '/' ) do |component| if current_user.nil? - component.navigation_item(text: 'Case logs', href: case_logs_path) + component.navigation_item(text: 'Sign in', href: user_session_path) elsif + component.navigation_item(text: 'Case logs', href: case_logs_path) component.navigation_item(text: 'Your organisation', href: "/organisations/#{current_user.organisation.id}") - component.navigation_item(text: 'Your account', href: '/users/account') + component.navigation_item(text: 'Your account', href: users_account_path) component.navigation_item(text: 'Sign out', href: destroy_user_session_path, options: {:method => :delete}) end end diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index 45bf33cb9..d70e33ec8 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -87,12 +87,12 @@ RSpec.describe "User Features" do it "Can navigate and sign in page with sign in button" do visit("/") - expect(page).to have_link("Case logs") - click_link("Case logs") + expect(page).to have_link("Sign in") + click_link("Sign in") fill_in("user[email]", with: user.email) fill_in("user[password]", with: "pAssword1") click_button("Sign in") - expect(page).to have_current_path("/case-logs") + expect(page).to have_current_path("/") end it "tries to access account page, redirects to log in page" do