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
Fix specs
Dombi Attila486ce0c96bc5
diff --git a/lib/custom_field_form_builder.rb b/lib/custom_field_form_builder.rbindex 43e84daa00b..836361c992d 100644--- a/lib/custom_field_form_builder.rb+++ b/lib/custom_field_form_builder.rb@@ -96,7 +96,11 @@ class CustomFieldFormBuilder < TabularFormBuilderselected_options = Array(selected).map(&:value)if custom_field.version?- template.grouped_options_for_select(options.group_by(&:last).to_a, selected_options)+ grouped_options = Hash.new { |hsh, key| hsh[key] = [] }+ options.each do |label, value, group_key|+ grouped_options[group_key] << [label, value]+ end+ template.grouped_options_for_select(grouped_options, selected_options)elsetemplate.options_for_select(options, selected_options)enddiff --git a/spec/lib/custom_field_form_builder_spec.rb b/spec/lib/custom_field_form_builder_spec.rbindex f5563b63efa..4eac6fc9a78 100644--- a/spec/lib/custom_field_form_builder_spec.rb+++ b/spec/lib/custom_field_form_builder_spec.rb@@ -339,7 +339,7 @@ RSpec.describe CustomFieldFormBuilder do.and_return(scope)allow(scope)- .to receive(:includes)+ .to receive(:references).and_return([version1, version2])endend@@ -355,8 +355,12 @@ RSpec.describe CustomFieldFormBuilder doname="user[#{custom_field.id}]"no_label="true"><option value="" label=" "></option>- <option value="#{version1.id}">#{version1.name}</option>- <option value="#{version2.id}">#{version2.name}</option>+ <optgroup label="#{version1.project.name}">+ <option value="#{version1.id}">#{version1.name}</option>+ </optgroup>+ <optgroup label="#{version2.project.name}">+ <option value="#{version2.id}">#{version2.name}</option>+ </optgroup></select>}).at_path("select")end@@ -373,8 +377,12 @@ RSpec.describe CustomFieldFormBuilder doname="user[#{custom_field.id}]"no_label="true"><option value="">--- Please select ---</option>- <option value="#{version1.id}">#{version1.name}</option>- <option value="#{version2.id}">#{version2.name}</option>+ <optgroup label="#{version1.project.name}">+ <option value="#{version1.id}">#{version1.name}</option>+ </optgroup>+ <optgroup label="#{version2.project.name}">+ <option value="#{version2.id}">#{version2.name}</option>+ </optgroup></select>}).at_path("select")enddiff --git a/spec/models/custom_actions/actions/custom_field_spec.rb b/spec/models/custom_actions/actions/custom_field_spec.rbindex 04ec6aaf8ce..644856e5988 100644--- a/spec/models/custom_actions/actions/custom_field_spec.rb+++ b/spec/models/custom_actions/actions/custom_field_spec.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -110,7 +112,7 @@ RSpec.describe CustomActions::Actions::CustomField doexpect(described_class.all.map(&:custom_field)).to match_array(custom_fields)- described_class.all.each do |subclass|+ described_class.find_each do |subclass|expect(subclass.ancestors).to include(described_class)endend@@ -408,7 +410,8 @@ RSpec.describe CustomActions::Actions::CustomField dobefore doallow(scope)- .to receive(:includes)+ .to receive(:references)+ .with(:project).and_return(versions)allow(Version)@@ -555,7 +558,8 @@ RSpec.describe CustomActions::Actions::CustomField dobefore doallow(scope)- .to receive(:includes)+ .to receive(:references)+ .with(:project).and_return(versions)allow(Version)@@ -577,8 +581,8 @@ RSpec.describe CustomActions::Actions::CustomField doit_behaves_like "bool custom action validations" dolet(:allowed_values) do[- { true: OpenProject::Database::DB_VALUE_TRUE },- { false: OpenProject::Database::DB_VALUE_FALSE }+ { true => OpenProject::Database::DB_VALUE_TRUE },+ { false => OpenProject::Database::DB_VALUE_FALSE }]endenddiff --git a/spec/models/custom_field_spec.rb b/spec/models/custom_field_spec.rbindex 51b4e378f5b..56dde15fad2 100644--- a/spec/models/custom_field_spec.rb+++ b/spec/models/custom_field_spec.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -156,7 +158,7 @@ RSpec.describe CustomField doit "is not valid" doexpect(field)- .to be_invalid+ .not_to be_validendend@@ -295,7 +297,7 @@ RSpec.describe CustomField dobefore dofield.field_format = "version"allow(shared_versions_scope)- .to receive(:includes)+ .to receive(:references).with(:project).and_return(versions)end