Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix specs for removing _limi_custom_fields_validation_to_section_id in Projects::UpdateContract

Dombi Attila8cf0732f2457
diff --git a/spec/models/projects/customizable_spec.rb b/spec/models/projects/customizable_spec.rb
index 2dffb1136d2..b9d5d72ffb3 100644
--- a/spec/models/projects/customizable_spec.rb
+++ b/spec/models/projects/customizable_spec.rb
@@ -190,7 +190,7 @@ RSpec.describe Project, "customizable" do
expect { project.save! }.to raise_error(ActiveRecord::RecordInvalid)
end
- it "temporarly validates only custom values of a section if section scope is provided while updating" do
+ it "validates only custom values of a section if section scope is provided while updating" do
project = create(:project, custom_field_values: {
text_custom_field.id => "foo",
bool_custom_field.id => true,
@@ -217,7 +217,8 @@ RSpec.describe Project, "customizable" do
expect { project.save! }.not_to raise_error
- # section scope is resetted after each update
+ # Removing the section scoped limitation should result a validation error again.
+ project._limit_custom_fields_validation_to_section_id = nil
expect { project.save! }.to raise_error(ActiveRecord::RecordInvalid)
end
end
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb
index 53c5bad035b..3c511e35298 100644
--- a/spec/services/projects/update_service_spec.rb
+++ b/spec/services/projects/update_service_spec.rb
@@ -79,5 +79,14 @@ RSpec.describe Projects::UpdateService, type: :model do
subject
end
end
+
+ describe "section based validation" do
+ it "is reset after the save is done" do
+ model_instance._limit_custom_fields_validation_to_section_id = 1
+ subject
+ # section scope is reset after the update
+ expect(model_instance._limit_custom_fields_validation_to_section_id).to be_nil
+ end
+ end
end
end