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

Update specs.

Dombi Attila61204f6f9f7b
diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/update_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/update_spec.rb
index 83336ed1d69..a3e3f2954a3 100644
--- a/spec/features/projects/project_custom_fields/overview_page/dialog/update_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/dialog/update_spec.rb
@@ -663,10 +663,29 @@ RSpec.describe "Edit project custom fields on project overview page", :js do
end
it "does not clears them after a project admin updates" do
+ # To make the expectations correct, we create an empty custom value for the other
+ # project's custom field too. This would happen in the code anyway.
+ # Due to the design of the acts_as_customizable plugin and the patch, it will create
+ # empty custom values for all the existing custom fields, regardless if they are
+ # enabled in the project or not. This happens, because we want to maintain backward
+ # compatibility with the existing api, and allow the API to automatically enable
+ # custom fields without being activated in the project. This implies in defining
+ # all the custom field accessors on every project, and that leads to having the
+ # empty custom values created. This is a compromise to avoid further patching the
+ # aac plugin and increase complexity.
+ # An extra expectation is added to make sure we don't activate other custom fields,
+ # so there are no unwanted side effects.
+
+ create(:custom_value,
+ custom_field: boolean_project_custom_field_activated_in_other_project,
+ customized: project)
+
expected_custom_values =
project.custom_values.where.not(custom_field: string_project_custom_field)
.pluck(:customized_type, :customized_id, :custom_field_id, :value)
+ expected_custom_fields = project.project_custom_fields
+
overview_page.visit_page
overview_page.open_edit_dialog_for_section(section)
@@ -680,6 +699,7 @@ RSpec.describe "Edit project custom fields on project overview page", :js do
.pluck(:customized_type, :customized_id, :custom_field_id, :value)
expect(custom_values).to eq(expected_custom_values)
+ expect(project.project_custom_fields.reload).to eq(expected_custom_fields)
end
end
end
diff --git a/spec/features/projects/project_custom_fields/overview_page/shared_context.rb b/spec/features/projects/project_custom_fields/overview_page/shared_context.rb
index 9b3ca69b1ee..02ff40e0526 100644
--- a/spec/features/projects/project_custom_fields/overview_page/shared_context.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/shared_context.rb
@@ -228,10 +228,8 @@ RSpec.shared_context "with seeded projects, members and project custom fields" d
let(:all_fields) { input_fields + select_fields + multi_select_fields }
let!(:boolean_project_custom_field_activated_in_other_project) do
- field = create(:boolean_project_custom_field, projects: [other_project],
- name: "Other Boolean field",
- project_custom_field_section: section_for_input_fields)
- create(:custom_value, customized: project, custom_field: field, value: true)
- field
+ create(:boolean_project_custom_field, projects: [other_project],
+ name: "Other Boolean field",
+ project_custom_field_section: section_for_input_fields)
end
end