diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index cfe77e7d8..dbc16a10f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -19,4 +19,15 @@ module ApplicationHelper current_gestionnaire.try(:email) || current_administrateur.try(:email) end + + def root_path_for_profile(nav_bar_profile) + case nav_bar_profile + when :gestionnaire + gestionnaire_procedures_path + when :user + users_dossiers_path + else + root_path + end + end end diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index 9f86c9e25..c21be5eb8 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -4,7 +4,7 @@ .header-inner-content .flex.align-center - = link_to root_path, class: "header-logo" do + = link_to root_path_for_profile(nav_bar_profile), class: "header-logo" do %img{ src: image_url("header/logo-ds.svg"), alt: "Logo de demarches-simplifiees.fr" } - if nav_bar_profile == :gestionnaire && gestionnaire_signed_in? diff --git a/spec/views/layouts/_new_header_spec.rb b/spec/views/layouts/_new_header_spec.rb new file mode 100644 index 000000000..39a9ae58e --- /dev/null +++ b/spec/views/layouts/_new_header_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe 'layouts/_new_header.html.haml', type: :view do + describe 'logo link' do + before do + allow(controller).to receive(:nav_bar_profile).and_return(profile) + render + end + + subject { rendered } + + context 'when rendering for user' do + let(:profile) { :user } + + it { is_expected.to have_css("a.header-logo[href=\"#{users_dossiers_path}\"]") } + end + + context 'when rendering for gestionnaire' do + let(:profile) { :gestionnaire } + + it { is_expected.to have_css("a.header-logo[href=\"#{gestionnaire_procedures_path}\"]") } + end + end +end