From b07d546bc307defec8d04958e91905f18131650c Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Fri, 21 Jan 2022 12:21:50 +0000 Subject: [PATCH] Change title link (#236) * Change title link * Add tests --- app/views/layouts/application.html.erb | 2 +- spec/requests/user_controller_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 80b1cb6cd..660b80bb8 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -38,7 +38,7 @@ <%= govuk_header( logotype: 'GOV.UK', service_name: t('service_name'), - service_url: '/' + service_url: current_user.nil? ? "/" : '/logs' ) do |component| if current_user.nil? component.navigation_item(text: 'Sign in', href: user_session_path) diff --git a/spec/requests/user_controller_spec.rb b/spec/requests/user_controller_spec.rb index 2830f522b..0553aba95 100644 --- a/spec/requests/user_controller_spec.rb +++ b/spec/requests/user_controller_spec.rb @@ -90,6 +90,14 @@ RSpec.describe "password_reset", type: :request do end end end + + describe "title link" do + it "routes user to the /logs page" do + get "/", headers: headers, params: {} + expected_link = "href=\"/\">#{I18n.t('service_name')}" + expect(CGI.unescape_html(response.body)).to include(expected_link) + end + end end describe "#show" do @@ -224,4 +232,16 @@ RSpec.describe "password_reset", type: :request do end end end + + describe "title link" do + before do + sign_in user + end + + it "routes user to the /logs page" do + get "/", headers: headers, params: {} + expected_link = "href=\"/logs\">#{I18n.t('service_name')}" + expect(CGI.unescape_html(response.body)).to include(expected_link) + end + end end