help: add administration contact on /commencer pages

This commit is contained in:
Pierre de La Morinerie 2019-03-28 10:14:01 +00:00
parent e6351b5b1c
commit d267d782b8
5 changed files with 80 additions and 23 deletions

View file

@ -34,6 +34,10 @@ module Users
redirect_to new_user_registration_path
end
def procedure_for_help
Procedure.publiees.find_by(path: params[:path]) || Procedure.brouillons.find_by(path: params[:path])
end
private
def store_user_location!

View file

@ -1,6 +1,7 @@
-# We can't use &. because the controller may not implement #nav_bar_profile
- nav_bar_profile = controller.try(:nav_bar_profile)
- nav_bar_profile = controller.try(:nav_bar_profile) || :guest
- dossier = controller.try(:dossier_for_help)
- procedure = controller.try(:procedure_for_help)
.new-header{ class: current_page?(root_path) ? nil : "new-header-with-border" }
.header-inner-content
@ -88,9 +89,12 @@
%li
.header-help
- if dossier.present? && nav_bar_profile == :user
- if dossier.present? && nav_bar_profile == :user
= render partial: 'shared/help/help_dropdown_dossier', locals: { dossier: dossier }
- elsif procedure.present? && (nav_bar_profile == :user || nav_bar_profile == :guest)
= render partial: 'shared/help/help_dropdown_procedure', locals: { procedure: procedure }
- elsif nav_bar_profile == :gestionnaire
= render partial: 'shared/help/help_dropdown_gestionnaire'

View file

@ -0,0 +1,9 @@
.dropdown.help-dropdown
.button.primary.dropdown-button Aide
.dropdown-content.fade-in-down
%ul.dropdown-items
- if procedure.service.present?
= render partial: 'shared/help/dropdown_items/service_item',
locals: { service: procedure.service, title: "Une question sur cette démarche ?" }
= render partial: 'shared/help/dropdown_items/faq_item'

View file

@ -8,6 +8,24 @@ feature 'Getting help:' do
end
end
context 'on pages related to a procedure' do
let(:procedure) { create(:procedure, :published, :with_service) }
scenario 'a Help menu provides administration contacts and a link to the FAQ' do
visit commencer_path(path: procedure.path)
within('.new-header') do
expect(page).to have_help_menu
end
within('.help-dropdown') do
expect(page).to have_content(procedure.service.email)
expect(page).to have_content(procedure.service.telephone)
expect(page).to have_link(nil, href: FAQ_URL)
end
end
end
context 'as a signed-in user' do
let(:user) { create(:user) }
let(:procedure) { create(:procedure, :with_service) }

View file

@ -1,36 +1,58 @@
require 'spec_helper'
describe 'layouts/_new_header.html.haml', type: :view do
describe 'logo link' do
before do
before do
if user
sign_in user
allow(controller).to receive(:nav_bar_profile).and_return(profile)
render
end
end
subject { render }
context 'when rendering without context' do
let(:user) { nil }
let(:profile) { nil }
it { is_expected.to have_css("a.header-logo[href=\"#{root_path}\"]") }
it 'displays the Help link' do
expect(subject).to have_link('Aide', href: FAQ_URL)
end
subject { rendered }
context 'when on a procedure page' do
let(:procedure) { create(:procedure, :with_service) }
context 'when rendering for user' do
let(:user) { create(:user) }
let(:profile) { :user }
it { is_expected.to have_css("a.header-logo[href=\"#{dossiers_path}\"]") }
it { is_expected.to have_link("Dossiers", href: dossiers_path) }
it 'displays the Help button' do
expect(subject).to have_link("Aide", href: FAQ_URL)
before do
allow(controller).to receive(:procedure_for_help).and_return(procedure)
end
end
context 'when rendering for gestionnaire' do
let(:user) { create(:gestionnaire) }
let(:profile) { :gestionnaire }
it { is_expected.to have_css("a.header-logo[href=\"#{gestionnaire_procedures_path}\"]") }
it 'displays the Help dropdown menu' do
expect(rendered).to have_css(".help-dropdown")
expect(subject).to have_css(".help-dropdown")
end
end
end
context 'when rendering for user' do
let(:user) { create(:user) }
let(:profile) { :user }
it { is_expected.to have_css("a.header-logo[href=\"#{dossiers_path}\"]") }
it { is_expected.to have_link("Dossiers", href: dossiers_path) }
it 'displays the Help button' do
expect(subject).to have_link("Aide", href: FAQ_URL)
end
end
context 'when rendering for gestionnaire' do
let(:user) { create(:gestionnaire) }
let(:profile) { :gestionnaire }
it { is_expected.to have_css("a.header-logo[href=\"#{gestionnaire_procedures_path}\"]") }
it 'displays the Help dropdown menu' do
expect(subject).to have_css(".help-dropdown")
end
end
end