Groupe instructeur index
This commit is contained in:
parent
6a974663b0
commit
2749c00ce3
5 changed files with 77 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
@import "colors";
|
||||
@import "constants";
|
||||
|
||||
.pull-left {
|
||||
float: left;
|
||||
|
@ -48,3 +49,7 @@
|
|||
background: $orange-bg;
|
||||
color: $black;
|
||||
}
|
||||
|
||||
.mt-2 {
|
||||
margin-top: 2 * $default-spacer;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
module NewAdministrateur
|
||||
class GroupeInstructeursController < AdministrateurController
|
||||
ITEMS_PER_PAGE = 25
|
||||
|
||||
def index
|
||||
@procedure = procedure
|
||||
|
||||
@groupes_instructeurs = procedure
|
||||
.groupe_instructeurs
|
||||
.page(params[:page])
|
||||
.per(ITEMS_PER_PAGE)
|
||||
.order(:label)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def procedure
|
||||
current_administrateur
|
||||
.procedures
|
||||
.includes(:groupe_instructeurs)
|
||||
.find(params[:procedure_id])
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
= render partial: 'new_administrateur/breadcrumbs',
|
||||
locals: { steps: [link_to('Démarches', admin_procedures_path),
|
||||
link_to(@procedure.libelle, admin_procedure_path(@procedure)),
|
||||
'Groupes d’instructeurs'] }
|
||||
|
||||
.container.groupe-instructeur
|
||||
.card
|
||||
.card-title Gestion des Groupes
|
||||
|
||||
%table.table.mt-2
|
||||
%thead
|
||||
%tr
|
||||
%th{ colspan: 2 } Liste des groupes
|
||||
%tbody
|
||||
- @groupes_instructeurs.each do |group|
|
||||
%tr
|
||||
%td= group.label
|
||||
|
||||
= paginate @groupes_instructeurs
|
|
@ -350,6 +350,8 @@ Rails.application.routes.draw do
|
|||
get 'annotations'
|
||||
end
|
||||
|
||||
resources :groupe_instructeurs, only: [:index]
|
||||
|
||||
resources :administrateurs, controller: 'procedure_administrateurs', only: [:index, :create, :destroy]
|
||||
|
||||
resources :types_de_champ, only: [:create, :update, :destroy] do
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
describe NewAdministrateur::GroupeInstructeursController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:admin) { create(:administrateur) }
|
||||
let(:procedure) { create(:procedure, :published, administrateurs: [admin]) }
|
||||
let!(:gi_1_1) { procedure.defaut_groupe_instructeur }
|
||||
|
||||
let(:procedure2) { create(:procedure, :published) }
|
||||
let!(:gi_2_2) { procedure2.groupe_instructeurs.create(label: 'groupe instructeur 2 2') }
|
||||
|
||||
before { sign_in(admin.user) }
|
||||
|
||||
describe '#index' do
|
||||
context 'of a procedure I own' do
|
||||
let!(:gi_1_2) { procedure.groupe_instructeurs.create(label: 'groupe instructeur 2') }
|
||||
|
||||
before { get :index, params: { procedure_id: procedure.id } }
|
||||
|
||||
context 'when a procedure has multiple groups' do
|
||||
it { expect(response).to have_http_status(:ok) }
|
||||
it { expect(response.body).to include(gi_1_1.label) }
|
||||
it { expect(response.body).to include(gi_1_2.label) }
|
||||
it { expect(response.body).not_to include(gi_2_2.label) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue