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
Respect allow_non_open_versions setting on the version input, do not wait on non existence expectations.
Dombi Attilaa1b612d5d824
diff --git a/app/forms/custom_fields/inputs/single_version_select_list.rb b/app/forms/custom_fields/inputs/single_version_select_list.rbindex 18ebebd03ff..19f832c916d 100644--- a/app/forms/custom_fields/inputs/single_version_select_list.rb+++ b/app/forms/custom_fields/inputs/single_version_select_list.rb@@ -27,6 +27,10 @@#++class CustomFields::Inputs::SingleVersionSelectList < CustomFields::Inputs::Base::Autocomplete::SingleValueInput+ include AssignableCustomFieldValues++ delegate :assignable_versions, to: :@object+form do |custom_value_form|# autocompleter does not set key with blank value if nothing is selected or input is cleared# in order to let acts_as_customizable handle the clearing of the value, we need to set the value to blank via a hidden field@@ -34,8 +38,7 @@ class CustomFields::Inputs::SingleVersionSelectList < CustomFields::Inputs::Basecustom_value_form.hidden(**input_attributes.merge(value: ""))custom_value_form.autocompleter(**input_attributes) do |list|- # TODO: allow-non-open version setting is not yet respected!- @object.versions.each do |version|+ assignable_custom_field_values(@custom_field).each do |version|list.option(label: version.name, value: version.id,selected: selected?(version)diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/inputs_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/inputs_spec.rbindex 549b10d15c4..17efbefbeb4 100644--- a/spec/features/projects/project_custom_fields/overview_page/dialog/inputs_spec.rb+++ b/spec/features/projects/project_custom_fields/overview_page/dialog/inputs_spec.rb@@ -295,17 +295,51 @@ RSpec.describe 'Edit project custom fields on project overview page', :js doit_behaves_like 'a autocomplete single select field'describe 'with correct version scoping' do- let!(:version_in_other_project) do- create(:version, name: 'Version 1 in other project', project: other_project)+ context 'with a version on a different project' do+ let!(:version_in_other_project) do+ create(:version, name: 'Version 1 in other project', project: other_project)+ end++ it 'shows only versions that are associated with this project' do+ overview_page.open_edit_dialog_for_section(section)++ field.search('Version 1')++ field.expect_option(first_version.name)+ field.expect_no_option(version_in_other_project.name)+ endend- it 'shows only versions that are associated with this project' do- overview_page.open_edit_dialog_for_section(section)+ context 'with a closed version' do+ let!(:closed_version) { create(:version, name: 'Closed version', project:, status: 'closed') }- field.search('Version 1')+ before do+ custom_field.update(allow_non_open_versions:)+ end- field.expect_option(first_version.name)- field.expect_no_option(version_in_other_project.name)+ context 'when non-open versions are not allowed' do+ let(:allow_non_open_versions) { false }++ it 'does not shows closed version option' do+ overview_page.open_edit_dialog_for_section(section)+ field.open_options++ field.expect_option(first_version.name)+ field.expect_no_option(closed_version.name)+ end+ end++ context 'when non-open versions are allowed' do+ let(:allow_non_open_versions) { true }++ it 'shows closed version option' do+ overview_page.open_edit_dialog_for_section(section)+ field.open_options++ field.expect_option(first_version.name)+ field.expect_option(closed_version.name)+ end+ endendendenddiff --git a/spec/support/form_fields/primerized/autocomplete_field.rb b/spec/support/form_fields/primerized/autocomplete_field.rbindex fb1d325310d..8e4b0bf37e0 100644--- a/spec/support/form_fields/primerized/autocomplete_field.rb+++ b/spec/support/form_fields/primerized/autocomplete_field.rb@@ -28,6 +28,10 @@ module FormFieldsfield_container.find('.ng-select-container input').set textend+ def open_options+ field_container.find('.ng-select-container').click+ end+def clearfield_container.find('.ng-clear-wrapper', visible: :all).clickend@@ -42,7 +46,7 @@ module FormFieldsdef expect_not_selected(*values)values.each do |val|- expect(field_container).to have_no_css('.ng-value', text: val)+ expect(field_container).to have_no_css('.ng-value', text: val, wait: 1)endend@@ -52,7 +56,7 @@ module FormFieldsdef expect_no_option(option)expect(page)- .to have_no_css('.ng-option', text: option, visible: :all)+ .to have_no_css('.ng-option', text: option, visible: :all, wait: 1)enddef expect_option(option)