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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#58865] fixed flaky custom fields specs
Eric Schubert797e0ff7bdaf
diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rbindex 2f2e907304e..9a7607bb245 100644--- a/app/helpers/custom_fields_helper.rb+++ b/app/helpers/custom_fields_helper.rb@@ -186,10 +186,7 @@ module CustomFieldsHelper# Return a string used to display a custom valuedef format_value(value, custom_field)- custom_value = CustomValue.new(custom_field:,- value:)-- custom_value.formatted_value+ CustomValue.new(custom_field:, value:).formatted_valueend# Return an array of custom field formats which can be used in select_tag@@ -208,15 +205,14 @@ module CustomFieldsHelperenddef label_for_custom_field_format(format_string)- show_enterprise_text = format_string == "hierarchy" && !EnterpriseToken.allows_to?(:custom_field_hierarchies)-format = OpenProject::CustomFieldFormat.find_by(name: format_string)- label = if format- format.label.is_a?(Proc) ? format.label.call : I18n.t(format.label)- end+ return "" if format.nil?++ label = format.label.is_a?(Proc) ? format.label.call : I18n.t(format.label)- label += " (#{I18n.t(:label_enterprise_addon)})" if show_enterprise_text+ show_enterprise_text = format_string == "hierarchy" && !EnterpriseToken.allows_to?(:custom_field_hierarchies)+ suffix = show_enterprise_text ? " (#{I18n.t(:label_enterprise_addon)})" : ""- label+ "#{label}#{suffix}"endenddiff --git a/app/models/permitted_params.rb b/app/models/permitted_params.rbindex 34d36be2cfc..ba22823578b 100644--- a/app/models/permitted_params.rb+++ b/app/models/permitted_params.rb@@ -474,7 +474,6 @@ class PermittedParams:searchable,:admin_only,:default_value,- :possible_values,:multi_value,:content_right_to_left,:custom_field_section_id,diff --git a/app/views/custom_fields/_custom_options.html.erb b/app/views/custom_fields/_custom_options.html.erbindex f20f6934f71..3f8b60b1f70 100644--- a/app/views/custom_fields/_custom_options.html.erb+++ b/app/views/custom_fields/_custom_options.html.erb@@ -86,13 +86,17 @@ See COPYRIGHT and LICENSE files for more details.><td><span class="dragula-handle icon icon-table icon-drag-handle"></span>- <%= co_f.hidden_field :id, class: 'custom-option-id' %>+ <%= co_f.hidden_field :id,+ disabled:true,+ class: 'custom-option-id' %><%= co_f.text_field :value,+ disabled: true,container_class: 'custom-option-value',no_label: true %></td><td><%= co_f.check_box :default_value,+ disabled: true,container_class: 'custom-option-default-value',data: {'admin--custom-fields-target': 'customOptionDefaults',diff --git a/app/views/custom_fields/edit.html.erb b/app/views/custom_fields/edit.html.erbindex dba36d962c7..cce977d0236 100644--- a/app/views/custom_fields/edit.html.erb+++ b/app/views/custom_fields/edit.html.erb@@ -33,7 +33,10 @@ See COPYRIGHT and LICENSE files for more details.<%= error_messages_for 'custom_field' %>-<% content_controller "admin--custom-fields", dynamic: true %>+<% content_controller "admin--custom-fields",+ dynamic: true,+ 'admin--custom-fields-format-config-value': OpenProject::CustomFieldFormatDependent.stimulus_config+%><% if @custom_field.field_format_hierarchy? %><%= render CustomFields::DetailsComponent.new(@custom_field) %>diff --git a/app/views/custom_fields/new.html.erb b/app/views/custom_fields/new.html.erbindex e5a49ea86e6..e83345b9aee 100644--- a/app/views/custom_fields/new.html.erb+++ b/app/views/custom_fields/new.html.erb@@ -45,7 +45,7 @@ See COPYRIGHT and LICENSE files for more details.<% content_controller "admin--custom-fields",dynamic: true,'admin--custom-fields-format-config-value': OpenProject::CustomFieldFormatDependent.stimulus_config,- 'admin--custom-fields-enterprise-edition-value': EnterpriseToken.active?+ 'admin--custom-fields-enterprise-edition-value': EnterpriseToken.allows_to?(:custom_field_hierarchies)%><%= labelled_tabular_form_for @custom_field, as: :custom_field,diff --git a/spec/features/admin/custom_fields/user_custom_field_spec.rb b/spec/features/admin/custom_fields/user_custom_field_spec.rbindex 58a76a7363c..146c5def776 100644--- a/spec/features/admin/custom_fields/user_custom_field_spec.rb+++ b/spec/features/admin/custom_fields/user_custom_field_spec.rb@@ -31,6 +31,7 @@ require "spec_helper"RSpec.describe "User custom fields edit", :js, :with_cuprite doshared_let(:admin) { create(:admin) }let(:cf_page) { Pages::CustomFields::IndexPage.new }+ let(:new_cf_page) { Pages::CustomFields::NewPage.new }before dologin_as(admin)@@ -39,30 +40,30 @@ RSpec.describe "User custom fields edit", :js, :with_cuprite doit "can create and edit user custom fields (#48725)" do# Create CF- click_link "Create a new custom field"+ click_on "New custom field"+ new_cf_page.expect_current_path- wait_for_reload-- fill_in "custom_field_name", with: "My User CF"- select "User", from: "custom_field_field_format"+ fill_in "Name", with: "My User CF"+ select "User", from: "Format"expect(page).to have_no_field("custom_field_custom_options_attributes_0_value")click_on "Save"# Expect field to be created- cf = CustomField.last- expect(cf.name).to eq("My User CF")+ cf_page.expect_current_path("tab=WorkPackageCustomField")+ expect(page).to have_list_item("My User CF")# Edit again- find("a", text: "My User CF").click+ click_on "My User CF"expect(page).to have_no_field("custom_field_custom_options_attributes_0_value")- fill_in "custom_field_name", with: "My User CF (edited)"+ fill_in "Name", with: "My User CF (edited)"click_on "Save"# Expect field to be saved+ expect(page).to have_css(".PageHeader-title", text: "My User CF (edited)")cf = CustomField.lastexpect(cf.name).to eq("My User CF (edited)")enddiff --git a/spec/features/custom_fields/hierarchy_custom_field_spec.rb b/spec/features/custom_fields/hierarchy_custom_field_spec.rbindex d7632338978..68542e168e2 100644--- a/spec/features/custom_fields/hierarchy_custom_field_spec.rb+++ b/spec/features/custom_fields/hierarchy_custom_field_spec.rb@@ -31,14 +31,18 @@require "spec_helper"RSpec.describe "custom fields of type hierarchy", :js, :with_cuprite do- let(:user) { create(:admin) }+ let(:admin) { create(:admin) }let(:custom_field_index_page) { Pages::CustomFields::IndexPage.new }let(:new_custom_field_page) { Pages::CustomFields::NewPage.new }let(:hierarchy_page) { Pages::CustomFields::HierarchyPage.new }+ before do+ allow(EnterpriseToken).to receive(:allows_to?).and_return(true)+ end+it "lets you create, update and delete a custom field of type hierarchy",with_flag: { custom_field_of_type_hierarchy: true } do- login_as user+ login_as admin# region CustomField creation