Fix proposals phase end date validation
So now it uses the same rules as the other phases.
This commit is contained in:
@@ -52,6 +52,7 @@ class Legislation::Process < ApplicationRecord
|
||||
validates :draft_end_date, presence: true, if: :draft_start_date?
|
||||
validates :allegations_start_date, presence: true, if: :allegations_end_date?
|
||||
validates :allegations_end_date, presence: true, if: :allegations_start_date?
|
||||
validates :proposals_phase_start_date, presence: true, if: :proposals_phase_end_date?
|
||||
validates :proposals_phase_end_date, presence: true, if: :proposals_phase_start_date?
|
||||
validate :valid_date_ranges
|
||||
validates :background_color, format: { allow_blank: true, with: CSS_HEX_COLOR }
|
||||
|
||||
@@ -53,6 +53,14 @@ describe Legislation::Process do
|
||||
expect(process.errors.messages[:proposals_phase_end_date]).to include("can't be blank")
|
||||
end
|
||||
|
||||
it "is invalid if proposals_phase_end_date is present but proposals_phase_start_date is not" do
|
||||
process = build(:legislation_process, proposals_phase_start_date: nil,
|
||||
proposals_phase_end_date: Date.current)
|
||||
|
||||
expect(process).to be_invalid
|
||||
expect(process.errors.messages[:proposals_phase_start_date]).to include("can't be blank")
|
||||
end
|
||||
|
||||
it "is invalid if allegations_start_date is present but allegations_end_date is not" do
|
||||
process = build(:legislation_process, allegations_start_date: Date.current,
|
||||
allegations_end_date: "")
|
||||
|
||||
Reference in New Issue
Block a user