diff --git a/app/controllers/legislation/processes_controller.rb b/app/controllers/legislation/processes_controller.rb index ee5c10830..adb7906fa 100644 --- a/app/controllers/legislation/processes_controller.rb +++ b/app/controllers/legislation/processes_controller.rb @@ -13,14 +13,13 @@ class Legislation::ProcessesController < Legislation::BaseController if @process.allegations_phase.enabled? && @process.allegations_phase.started? && draft_version.present? redirect_to legislation_process_draft_version_path(@process, draft_version) elsif @process.debate_phase.enabled? - redirect_to legislation_process_debate_path(@process) + redirect_to debate_legislation_process_path(@process) else - redirect_to legislation_process_allegations_path(@process) + redirect_to allegations_legislation_process_path(@process) end end def debate - set_process @phase = :debate_phase if @process.debate_phase.started? @@ -31,7 +30,6 @@ class Legislation::ProcessesController < Legislation::BaseController end def draft_publication - set_process @phase = :draft_publication if @process.draft_publication.started? @@ -48,7 +46,6 @@ class Legislation::ProcessesController < Legislation::BaseController end def allegations - set_process @phase = :allegations_phase if @process.allegations_phase.started? @@ -65,7 +62,6 @@ class Legislation::ProcessesController < Legislation::BaseController end def result_publication - set_process @phase = :result_publication if @process.result_publication.started? @@ -81,9 +77,5 @@ class Legislation::ProcessesController < Legislation::BaseController end end - private - def set_process - @process = ::Legislation::Process.find(params[:process_id]) - end end diff --git a/app/views/legislation/processes/_key_dates.html.erb b/app/views/legislation/processes/_key_dates.html.erb index d6131034b..375be7d51 100644 --- a/app/views/legislation/processes/_key_dates.html.erb +++ b/app/views/legislation/processes/_key_dates.html.erb @@ -9,7 +9,7 @@
<%= format_date(process.debate_start_date) %> - <%= format_date(process.debate_end_date) %>
<% end %> @@ -18,7 +18,7 @@ <% if process.draft_publication.enabled? %><%= format_date(process.draft_publication_date) %>
<% end %> @@ -27,7 +27,7 @@ <% if process.allegations_phase.enabled? %><%= format_date(process.allegations_start_date) %> - <%= format_date(process.allegations_end_date) %>
<% end %> @@ -36,7 +36,7 @@ <% if process.result_publication.enabled? %><%= format_date(process.result_publication_date) %>
<% end %> diff --git a/config/routes.rb b/config/routes.rb index ef476cf28..dbf3e4709 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -109,10 +109,12 @@ Rails.application.routes.draw do namespace :legislation do resources :processes, only: [:index, :show] do - get :debate - get :draft_publication - get :allegations - get :result_publication + member do + get :debate + get :draft_publication + get :allegations + get :result_publication + end resources :questions, only: [:show] do resources :answers, only: [:create] end diff --git a/spec/features/legislation/processes_spec.rb b/spec/features/legislation/processes_spec.rb index 3ed4ccb74..282b13191 100644 --- a/spec/features/legislation/processes_spec.rb +++ b/spec/features/legislation/processes_spec.rb @@ -70,7 +70,7 @@ feature 'Legislation' do scenario 'not open' do process = create(:legislation_process, draft_publication_date: Date.current + 1.day) - visit legislation_process_draft_publication_path(process) + visit draft_publication_legislation_process_path(process) expect(page).to have_content("This phase is not open yet") end @@ -78,7 +78,7 @@ feature 'Legislation' do scenario 'open' do process = create(:legislation_process, draft_publication_date: Date.current) - visit legislation_process_draft_publication_path(process) + visit draft_publication_legislation_process_path(process) expect(page).to have_content("Nothing published yet") end @@ -88,7 +88,7 @@ feature 'Legislation' do scenario 'not open' do process = create(:legislation_process, allegations_start_date: Date.current + 1.day, allegations_end_date: Date.current + 2.days) - visit legislation_process_allegations_path(process) + visit allegations_legislation_process_path(process) expect(page).to have_content("This phase is not open yet") end @@ -96,7 +96,7 @@ feature 'Legislation' do scenario 'open' do process = create(:legislation_process, allegations_start_date: Date.current - 1.day, allegations_end_date: Date.current + 2.days) - visit legislation_process_allegations_path(process) + visit allegations_legislation_process_path(process) expect(page).to have_content("Nothing published yet") end @@ -106,7 +106,7 @@ feature 'Legislation' do scenario 'not open' do process = create(:legislation_process, result_publication_date: Date.current + 1.day) - visit legislation_process_result_publication_path(process) + visit result_publication_legislation_process_path(process) expect(page).to have_content("This phase is not open yet") end @@ -114,7 +114,7 @@ feature 'Legislation' do scenario 'open' do process = create(:legislation_process, result_publication_date: Date.current) - visit legislation_process_result_publication_path(process) + visit result_publication_legislation_process_path(process) expect(page).to have_content("Nothing published yet") end