Add 'mes dossiers' link in navbar
This commit is contained in:
parent
0c67cda7c5
commit
64d27e0088
3 changed files with 99 additions and 38 deletions
42
app/views/layouts/_navbar.html.haml
Normal file
42
app/views/layouts/_navbar.html.haml
Normal file
|
@ -0,0 +1,42 @@
|
|||
#beta
|
||||
Beta
|
||||
= image_tag('marianne_small.png', class: 'logo')
|
||||
%a{href: '/'}
|
||||
= image_tag('logo-tps.png', class: 'logo')
|
||||
%a{href: '/'}
|
||||
-if gestionnaire_signed_in?
|
||||
%span{ style: 'margin-left: 25px;' }
|
||||
%b
|
||||
Mes Dossiers
|
||||
|
||||
#sign_out
|
||||
-if gestionnaire_signed_in?
|
||||
= render partial: 'gestionnaires/login_banner'
|
||||
-elsif administrateur_signed_in?
|
||||
= render partial: 'administrateurs/login_banner'
|
||||
- elsif user_signed_in?
|
||||
%div.user
|
||||
-if current_user.loged_in_with_france_connect?
|
||||
%div{ id: "fconnect-profile", "data-fc-logout-url" => '/users/sign_out" data-method="delete' }
|
||||
%a.text-info{ href: "#" }
|
||||
= "#{current_user.given_name} #{current_user.family_name}"
|
||||
|
||||
= link_to "", '/users/sign_out', method: :delete, :class => 'btn fa fa-power-off off-fc-link'
|
||||
|
||||
-else
|
||||
%i.fa.fa-user
|
||||
= current_user.email
|
||||
|
||||
= link_to "Déconnexion", '/users/sign_out', method: :delete, :class => 'btn btn-md'
|
||||
- else
|
||||
= link_to "Utilisateur", '/users/sign_in', method: :get, :class => 'btn btn-md'
|
||||
= link_to "Accompagnateur", '/gestionnaires/sign_in', method: :get, :class => 'btn btn-md'
|
||||
= link_to "Administrateur", '/administrateurs/sign_in', method: :get, :class => 'btn btn-md'
|
||||
|
||||
#flash_message.center
|
||||
- if flash.notice
|
||||
.alert.alert-success
|
||||
= flash.notice
|
||||
- if flash.alert
|
||||
.alert.alert-danger
|
||||
= flash.alert
|
|
@ -12,44 +12,7 @@
|
|||
%body
|
||||
%div#wrap
|
||||
%div#header.navbar
|
||||
|
||||
#beta
|
||||
Beta
|
||||
= image_tag('marianne_small.png', class: 'logo')
|
||||
%a{href: '/'}
|
||||
= image_tag('logo-tps.png', class: 'logo')
|
||||
|
||||
#sign_out
|
||||
-if gestionnaire_signed_in?
|
||||
= render partial: 'gestionnaires/login_banner'
|
||||
-elsif administrateur_signed_in?
|
||||
= render partial: 'administrateurs/login_banner'
|
||||
- elsif user_signed_in?
|
||||
%div.user
|
||||
-if current_user.loged_in_with_france_connect?
|
||||
%div{ id: "fconnect-profile", "data-fc-logout-url" => '/users/sign_out" data-method="delete' }
|
||||
%a.text-info{ href: "#" }
|
||||
= "#{current_user.given_name} #{current_user.family_name}"
|
||||
|
||||
= link_to "", '/users/sign_out', method: :delete, :class => 'btn fa fa-power-off off-fc-link'
|
||||
|
||||
-else
|
||||
%i.fa.fa-user
|
||||
= current_user.email
|
||||
|
||||
= link_to "Déconnexion", '/users/sign_out', method: :delete, :class => 'btn btn-md'
|
||||
- else
|
||||
= link_to "Utilisateur", '/users/sign_in', method: :get, :class => 'btn btn-md'
|
||||
= link_to "Accompagnateur", '/gestionnaires/sign_in', method: :get, :class => 'btn btn-md'
|
||||
= link_to "Administrateur", '/administrateurs/sign_in', method: :get, :class => 'btn btn-md'
|
||||
|
||||
#flash_message.center
|
||||
- if flash.notice
|
||||
.alert.alert-success
|
||||
= flash.notice
|
||||
- if flash.alert
|
||||
.alert.alert-danger
|
||||
= flash.alert
|
||||
=render partial: "layouts/navbar"
|
||||
|
||||
#main_div.main_div
|
||||
= yield
|
||||
|
|
56
spec/views/layouts/_navbar_spec.rb
Normal file
56
spec/views/layouts/_navbar_spec.rb
Normal file
|
@ -0,0 +1,56 @@
|
|||
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/) }
|
||||
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/) }
|
||||
it { is_expected.not_to match(/Mes Dossiers/) }
|
||||
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/) }
|
||||
it { is_expected.to match(/Mes Dossiers/) }
|
||||
it { is_expected.to match(/Se déconnecter/) }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue