mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
ease the validation on project phases
Validation will only take place when the project_phase_definition_id value is changed. Before, it was always validated (unless the project was changed). But with the larger amount of possibilities to disable project phases and with subsequent changes to the work package potentically being done by somebody who does not have the permission to change the value, the validation needs to be more precise.
This commit is contained in:
@@ -559,7 +559,7 @@ module WorkPackages
|
||||
def validate_phase_active_in_project
|
||||
if model.project.present? &&
|
||||
model.project_phase_definition_id.present? &&
|
||||
!(model.project_changed? && !model.project_phase_definition_changed?) &&
|
||||
model.project_phase_definition_changed? &&
|
||||
!project_definition_assignable?
|
||||
errors.add :project_phase_id, :inclusion
|
||||
end
|
||||
|
||||
@@ -343,6 +343,18 @@ RSpec.describe WorkPackages::UpdateContract do
|
||||
it_behaves_like "contract is valid"
|
||||
end
|
||||
|
||||
context "when not changing the value but changing a different attribute while the project phase is inactive" do
|
||||
before do
|
||||
work_package.project_phase_definition = persisted_inactive_project_phase.definition
|
||||
work_package.save
|
||||
work_package.reload
|
||||
|
||||
work_package.subject = "A new subject"
|
||||
end
|
||||
|
||||
it_behaves_like "contract is valid"
|
||||
end
|
||||
|
||||
context "when changing the value and assigning a project in which the phase is not active" do
|
||||
before do
|
||||
work_package.project_phase_definition = persisted_project_phase_definition
|
||||
|
||||
Reference in New Issue
Block a user