diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index 4d00955da..c229561bc 100755
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -193,6 +193,7 @@ en:
form:
error: Error
form:
+ active: Active
process: Process
debate_phase: Debate phase
allegations_phase: Allegations phase
diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml
index 79bf53187..e30df44c2 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -193,6 +193,7 @@ es:
form:
error: Error
form:
+ active: Activa
process: Proceso
debate_phase: Fase previa
allegations_phase: Fase de alegaciones
diff --git a/config/routes.rb b/config/routes.rb
index f5b65420e..c2639389f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -102,6 +102,7 @@ Rails.application.routes.draw do
namespace :legislation do
resources :processes, only: [:index, :show] do
+ get :debate
get :draft_publication
get :allegations
get :final_version_publication
diff --git a/spec/features/admin/legislation/processes_spec.rb b/spec/features/admin/legislation/processes_spec.rb
index 0f1114f51..2218ae8d5 100644
--- a/spec/features/admin/legislation/processes_spec.rb
+++ b/spec/features/admin/legislation/processes_spec.rb
@@ -59,4 +59,27 @@ feature 'Admin legislation processes' do
expect(page).to have_content 'An example legislation process'
end
end
+
+ context 'Update' do
+ scenario 'Deactivate debate phase', js: true do
+ process = create(:legislation_process, title: 'An example legislation process')
+ visit admin_root_path
+
+ within('#side_menu') do
+ click_link "Collaborative Legislation"
+ end
+
+ click_link "An example legislation process"
+
+ expect(page).to have_selector("h1", text: "An example legislation process")
+ expect(find("#debate_phase_active")).to be_checked
+
+ uncheck "debate_phase_active"
+ click_button "Save changes"
+
+ expect(page).to have_content "Process updated successfully"
+ expect(find("#debate_start_date").value).to be_blank
+ expect(find("#debate_end_date").value).to be_blank
+ end
+ end
end
diff --git a/spec/models/legislation/process_spec.rb b/spec/models/legislation/process_spec.rb
index fd83d8989..f89a4bfcf 100644
--- a/spec/models/legislation/process_spec.rb
+++ b/spec/models/legislation/process_spec.rb
@@ -7,6 +7,32 @@ RSpec.describe Legislation::Process, type: :model do
expect(process).to be_valid
end
+ describe "dates validations" do
+ it "is invalid if debate_start_date is present but debate_end_date is not" do
+ process = build(:legislation_process, debate_start_date: Date.current, debate_end_date: "")
+ expect(process).to be_invalid
+ expect(process.errors.messages[:debate_end_date]).to include("can't be blank")
+ end
+
+ it "is invalid if debate_end_date is present but debate_start_date is not" do
+ process = build(:legislation_process, debate_start_date: nil, debate_end_date: Date.current)
+ expect(process).to be_invalid
+ expect(process.errors.messages[:debate_start_date]).to include("can't be blank")
+ end
+
+ it "is invalid if allegations_start_date is present but debate_end_date is not" do
+ process = build(:legislation_process, allegations_start_date: Date.current, allegations_end_date: "")
+ expect(process).to be_invalid
+ expect(process.errors.messages[:allegations_end_date]).to include("can't be blank")
+ end
+
+ it "is invalid if debate_end_date is present but allegations_start_date is not" do
+ process = build(:legislation_process, allegations_start_date: nil, allegations_end_date: Date.current)
+ expect(process).to be_invalid
+ expect(process.errors.messages[:allegations_start_date]).to include("can't be blank")
+ end
+ end
+
describe "date ranges validations" do
it "is invalid if end_date is before start_date" do
process = build(:legislation_process, start_date: Date.current, end_date: Date.current - 1.day)