From 4c0592d631b98c66d7dd36ec8f1ade75175829a6 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 10 Jan 2018 17:42:21 +0100 Subject: [PATCH] Rails-ish route --- app/controllers/manager/procedures_controller.rb | 2 +- app/views/manager/procedures/show.html.haml | 2 +- config/routes.rb | 2 +- spec/controllers/manager/procedures_controller_spec.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/manager/procedures_controller.rb b/app/controllers/manager/procedures_controller.rb index 3d6fc6297..cb6a7eae9 100644 --- a/app/controllers/manager/procedures_controller.rb +++ b/app/controllers/manager/procedures_controller.rb @@ -1,7 +1,7 @@ module Manager class ProceduresController < Manager::ApplicationController def whitelist - procedure = Procedure.find(params[:procedure_id]) + procedure = Procedure.find(params[:id]) procedure.whitelist! redirect_to manager_procedure_path(procedure) end diff --git a/app/views/manager/procedures/show.html.haml b/app/views/manager/procedures/show.html.haml index d0174cb7b..dee910db0 100644 --- a/app/views/manager/procedures/show.html.haml +++ b/app/views/manager/procedures/show.html.haml @@ -21,7 +21,7 @@ %h1.header__heading= content_for(:title) .header__actions - if !procedure.whitelisted? - = link_to 'whitelister', manager_procedure_whitelist_path(procedure), method: :post, class: 'button' + = link_to 'whitelister', whitelist_manager_procedure_path(procedure), method: :post, class: 'button' %dl - page.attributes.each do |attribute| diff --git a/config/routes.rb b/config/routes.rb index e4a68bcd8..bc7198132 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,7 @@ Rails.application.routes.draw do namespace :manager do resources :procedures, only: [:index, :show] do - post '/whitelist' => 'procedures#whitelist' + post 'whitelist', on: :member end resources :administrateurs, only: [:index, :show] diff --git a/spec/controllers/manager/procedures_controller_spec.rb b/spec/controllers/manager/procedures_controller_spec.rb index c4ec5acce..69b133439 100644 --- a/spec/controllers/manager/procedures_controller_spec.rb +++ b/spec/controllers/manager/procedures_controller_spec.rb @@ -5,7 +5,7 @@ describe Manager::ProceduresController, type: :controller do before do sign_in administration - post :whitelist, procedure_id: procedure.id + post :whitelist, id: procedure.id procedure.reload end