2016-06-07 15:16:35 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'layouts/_navbar.html.haml', type: :view do
|
|
|
|
let(:administrateur) { create(:administrateur) }
|
|
|
|
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
|
|
|
|
|
|
|
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
|
|
|
|
|
|
|
describe 'navbar entries' do
|
|
|
|
|
|
|
|
context 'when disconnected' do
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
subject { rendered }
|
|
|
|
it { is_expected.to match(/href="\/users\/sign_in">Utilisateur/) }
|
|
|
|
it { is_expected.to match(/href="\/gestionnaires\/sign_in">Accompagnateur/) }
|
|
|
|
it { is_expected.to match(/href="\/administrateurs\/sign_in">Administrateur/) }
|
|
|
|
it { is_expected.not_to match(/Mes Dossiers/) }
|
2016-06-07 15:52:55 +02:00
|
|
|
it { is_expected.not_to match(/Mes Procédures/) }
|
2016-06-07 15:16:35 +02:00
|
|
|
it { is_expected.not_to match(/Se déconnecter/) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when administrateur is connected' do
|
|
|
|
before do
|
|
|
|
@request.env["devise.mapping"] = Devise.mappings[:administrateur]
|
|
|
|
@current_user = administrateur
|
|
|
|
sign_in @current_user
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { rendered }
|
|
|
|
it { is_expected.not_to match(/href="\/users\/sign_in">Utilisateur/) }
|
|
|
|
it { is_expected.not_to match(/href="\/gestionnaires\/sign_in">Accompagnateur/) }
|
|
|
|
it { is_expected.not_to match(/href="\/administrateurs\/sign_in">Administrateur/) }
|
2016-11-03 16:46:26 +01:00
|
|
|
it { is_expected.not_to match(/Mes dossiers/) }
|
|
|
|
it { is_expected.to match(/Mes procédures/) }
|
2016-06-07 15:16:35 +02:00
|
|
|
it { is_expected.to match(/Se déconnecter/) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when gestionnaire is connected' do
|
|
|
|
before do
|
|
|
|
@request.env["devise.mapping"] = Devise.mappings[:gestionnaire]
|
|
|
|
@current_user = gestionnaire
|
|
|
|
sign_in @current_user
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { rendered }
|
|
|
|
it { is_expected.not_to match(/href="\/users\/sign_in">Utilisateur/) }
|
|
|
|
it { is_expected.not_to match(/href="\/gestionnaires\/sign_in">Accompagnateur/) }
|
|
|
|
it { is_expected.not_to match(/href="\/administrateurs\/sign_in">Administrateur/) }
|
2016-11-03 16:46:26 +01:00
|
|
|
it { is_expected.not_to match(/Mes procédures/) }
|
|
|
|
it { is_expected.to match(/Mes dossiers/) }
|
2016-08-22 16:36:25 +02:00
|
|
|
it { is_expected.to match(/Déconnexion/) }
|
2016-06-07 15:16:35 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|