2018-03-08 13:54:26 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'layouts/_new_header.html.haml', type: :view do
|
2019-03-28 11:14:01 +01:00
|
|
|
before do
|
|
|
|
if user
|
2018-06-25 11:26:37 +02:00
|
|
|
sign_in user
|
2018-03-08 13:54:26 +01:00
|
|
|
allow(controller).to receive(:nav_bar_profile).and_return(profile)
|
|
|
|
end
|
2019-03-28 11:14:01 +01:00
|
|
|
end
|
2018-03-08 13:54:26 +01:00
|
|
|
|
2019-03-28 11:14:01 +01:00
|
|
|
subject { render }
|
2018-03-08 13:54:26 +01:00
|
|
|
|
2019-03-28 11:14:01 +01:00
|
|
|
context 'when rendering without context' do
|
|
|
|
let(:user) { nil }
|
|
|
|
let(:profile) { nil }
|
2018-03-08 13:54:26 +01:00
|
|
|
|
2019-03-28 11:14:01 +01:00
|
|
|
it { is_expected.to have_css("a.header-logo[href=\"#{root_path}\"]") }
|
2019-03-13 16:48:38 +01:00
|
|
|
|
2019-03-28 11:14:01 +01:00
|
|
|
it 'displays the Help link' do
|
|
|
|
expect(subject).to have_link('Aide', href: FAQ_URL)
|
2018-03-08 13:54:26 +01:00
|
|
|
end
|
|
|
|
|
2019-03-28 11:14:01 +01:00
|
|
|
context 'when on a procedure page' do
|
|
|
|
let(:procedure) { create(:procedure, :with_service) }
|
2018-03-08 13:54:26 +01:00
|
|
|
|
2019-03-28 11:14:01 +01:00
|
|
|
before do
|
|
|
|
allow(controller).to receive(:procedure_for_help).and_return(procedure)
|
|
|
|
end
|
2018-06-25 11:26:37 +02:00
|
|
|
|
2019-03-19 14:48:26 +01:00
|
|
|
it 'displays the Help dropdown menu' do
|
2019-03-28 11:14:01 +01:00
|
|
|
expect(subject).to have_css(".help-dropdown")
|
2018-06-25 11:26:37 +02:00
|
|
|
end
|
2018-03-08 13:54:26 +01:00
|
|
|
end
|
|
|
|
end
|
2019-03-28 11:14:01 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
context 'when rendering for instructeur' do
|
|
|
|
let(:user) { create(:instructeur) }
|
|
|
|
let(:profile) { :instructeur }
|
2019-03-28 11:14:01 +01:00
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
it { is_expected.to have_css("a.header-logo[href=\"#{instructeur_procedures_path}\"]") }
|
2019-03-28 11:14:01 +01:00
|
|
|
|
|
|
|
it 'displays the Help dropdown menu' do
|
|
|
|
expect(subject).to have_css(".help-dropdown")
|
|
|
|
end
|
|
|
|
end
|
2018-03-08 13:54:26 +01:00
|
|
|
end
|