rename avis#index to avis#procedure

This commit is contained in:
Christophe Robillard 2020-06-26 19:28:28 +02:00
parent 90d6d337a9
commit bbec76d33b
6 changed files with 12 additions and 11 deletions

View file

@ -15,7 +15,7 @@ module Instructeurs
@avis_by_procedure = avis.to_a.group_by(&:procedure) @avis_by_procedure = avis.to_a.group_by(&:procedure)
end end
def index def procedure
@procedure = Procedure.find(params[:procedure_id]) @procedure = Procedure.find(params[:procedure_id])
instructeur_avis = current_instructeur.avis.includes(:dossier).where(dossiers: { groupe_instructeur: GroupeInstructeur.where(procedure: @procedure.id) }) instructeur_avis = current_instructeur.avis.includes(:dossier).where(dossiers: { groupe_instructeur: GroupeInstructeur.where(procedure: @procedure.id) })
@avis_a_donner = instructeur_avis.without_answer @avis_a_donner = instructeur_avis.without_answer

View file

@ -2,7 +2,7 @@
.container .container
%ul.breadcrumbs %ul.breadcrumbs
%li= link_to('Avis', instructeur_all_avis_path) %li= link_to('Avis', instructeur_all_avis_path)
%li= link_to(dossier.procedure.libelle, instructeur_avis_index_path(avis.procedure)) %li= link_to(dossier.procedure.libelle, procedure_instructeur_avis_index_path(avis.procedure))
%li= link_to("Dossier nº #{dossier.id}", instructeur_avis_path(avis.procedure, avis)) %li= link_to("Dossier nº #{dossier.id}", instructeur_avis_path(avis.procedure, avis))
%ul.tabs %ul.tabs

View file

@ -6,7 +6,7 @@
%ul.procedure-list %ul.procedure-list
- @avis_by_procedure.each do |p, procedure_avis| - @avis_by_procedure.each do |p, procedure_avis|
%li.procedure-item.flex.align-start %li.procedure-item.flex.align-start
= link_to(instructeur_avis_index_path(p)) do = link_to(procedure_instructeur_avis_index_path(p)) do
.flex .flex
.procedure-logo{ style: "background-image: url(#{p.logo_url})" } .procedure-logo{ style: "background-image: url(#{p.logo_url})" }
@ -17,7 +17,7 @@
%ul.procedure-stats.flex %ul.procedure-stats.flex
%li %li
%object %object
= link_to(instructeur_avis_index_path(p, statut: Instructeurs::AvisController::A_DONNER_STATUS)) do = link_to(procedure_instructeur_avis_index_path(p, statut: Instructeurs::AvisController::A_DONNER_STATUS)) do
- without_answer_count = procedure_avis.select { |a| a.answer.nil? }.size - without_answer_count = procedure_avis.select { |a| a.answer.nil? }.size
- if without_answer_count > 0 - if without_answer_count > 0
%span.notifications{ 'aria-label': "notifications" } %span.notifications{ 'aria-label': "notifications" }
@ -27,7 +27,7 @@
avis à donner avis à donner
%li %li
%object %object
= link_to(instructeur_avis_index_path(p, statut: Instructeurs::AvisController::DONNES_STATUS)) do = link_to(procedure_instructeur_avis_index_path(p, statut: Instructeurs::AvisController::DONNES_STATUS)) do
- with_answer_count = procedure_avis.select { |a| a.answer.present? }.size - with_answer_count = procedure_avis.select { |a| a.answer.present? }.size
.stats-number= with_answer_count .stats-number= with_answer_count
.stats-legend .stats-legend

View file

@ -13,13 +13,13 @@
%ul.tabs %ul.tabs
= tab_item('avis à donner', = tab_item('avis à donner',
instructeur_avis_index_path(statut: Instructeurs::AvisController::A_DONNER_STATUS), procedure_instructeur_avis_index_path(statut: Instructeurs::AvisController::A_DONNER_STATUS),
active: @statut == Instructeurs::AvisController::A_DONNER_STATUS, active: @statut == Instructeurs::AvisController::A_DONNER_STATUS,
badge: @avis_a_donner.count, badge: @avis_a_donner.count,
notification: @avis_a_donner.any?) notification: @avis_a_donner.any?)
= tab_item("avis #{'donné'.pluralize(@avis_donnes.count)}", = tab_item("avis #{'donné'.pluralize(@avis_donnes.count)}",
instructeur_avis_index_path(statut: Instructeurs::AvisController::DONNES_STATUS), procedure_instructeur_avis_index_path(statut: Instructeurs::AvisController::DONNES_STATUS),
active: @statut == Instructeurs::AvisController::DONNES_STATUS, active: @statut == Instructeurs::AvisController::DONNES_STATUS,
badge: @avis_donnes.count) badge: @avis_donnes.count)

View file

@ -316,7 +316,8 @@ Rails.application.routes.draw do
end end
end end
resources :avis, only: [:index, :show, :update] do resources :avis, only: [:show, :update] do
get '', action: 'procedure', on: :collection, as: :procedure
member do member do
get 'instruction' get 'instruction'
get 'messagerie' get 'messagerie'

View file

@ -20,8 +20,8 @@ describe Instructeurs::AvisController, type: :controller do
it { expect(assigns(:avis_by_procedure).flatten).not_to include(another_procedure) } it { expect(assigns(:avis_by_procedure).flatten).not_to include(another_procedure) }
end end
describe '#index' do describe '#procedure' do
before { get :index, params: { procedure_id: procedure.id } } before { get :procedure, params: { procedure_id: procedure.id } }
it { expect(response).to have_http_status(:success) } it { expect(response).to have_http_status(:success) }
it { expect(assigns(:avis_a_donner)).to match([avis_without_answer]) } it { expect(assigns(:avis_a_donner)).to match([avis_without_answer]) }
@ -29,7 +29,7 @@ describe Instructeurs::AvisController, type: :controller do
it { expect(assigns(:statut)).to eq('a-donner') } it { expect(assigns(:statut)).to eq('a-donner') }
context 'with a statut equal to donnes' do context 'with a statut equal to donnes' do
before { get :index, params: { statut: 'donnes', procedure_id: procedure.id } } before { get :procedure, params: { statut: 'donnes', procedure_id: procedure.id } }
it { expect(assigns(:statut)).to eq('donnes') } it { expect(assigns(:statut)).to eq('donnes') }
end end