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 and add new specs for testing list project custom field search
Dombi Attilad7c683929644
diff --git a/lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rb b/lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rbindex d51c63f7bf6..376f5ee1dd7 100644--- a/lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rb+++ b/lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rb@@ -177,13 +177,14 @@ module Redmineenddef searchable_custom_fields_conditions- searchable_custom_field_ids = CustomField.where(type: "#{name}CustomField", searchable: true).pluck(:id)+ searchable_custom_field_ids = CustomField.where(type: "#{name}CustomField",+ searchable: true).pluck(:id)if searchable_custom_field_ids.any?custom_field_condition =CustomValue.select("1").where(customized_type: name).joins("LEFT JOIN custom_options- ON custom_options.id = custom_values.value::bigint- AND custom_options.custom_field_id = custom_values.custom_field_id")+ ON custom_options.custom_field_id = custom_values.custom_field_id+ AND custom_options.id::VARCHAR = custom_values.value").where("customized_id=#{table_name}.id").where(custom_field_id: searchable_custom_field_ids).where("(custom_values.value ILIKE ?) OR (custom_options.value ILIKE ?)")diff --git a/spec/features/search/search_spec.rb b/spec/features/search/search_spec.rbindex 3ac2850821b..4cfe499fb82 100644--- a/spec/features/search/search_spec.rb+++ b/spec/features/search/search_spec.rb@@ -495,6 +495,68 @@ RSpec.describe "Search", :js, with_settings: { per_page_options: "5" } doexpect(page).to have_no_link(other_project.name)end++ describe "searching for list project custom field" do+ let(:project_list_cf) do+ create(:list_project_custom_field,+ multi_value: true,+ projects: [searched_for_project],+ possible_values: %w[Value1 Value2 Value3],+ searchable:).tap do |cf|+ searched_for_project.update(+ custom_field_values: { cf.id => cf.possible_values.pluck(:id).first(2) }+ )+ end+ end+ let(:first_selected_value) { project_list_cf.possible_values.pick(:value) }++ before do+ select_autocomplete(page.find(".top-menu-search--input"),+ query: first_selected_value,+ select_text: "In all projects ↵",+ wait_dropdown_open: false)++ within ".global-search--tabs" do+ click_on "Projects"+ end+ end++ it "finds the project" do+ expect(page)+ .to have_link(searched_for_project.name)++ expect(page)+ .to have_no_link(other_project.name)+ end++ context "when searchable is false" do+ let(:searchable) { false }++ it "does not find the project" do+ expect(page)+ .to have_no_link(searched_for_project.name)++ expect(page)+ .to have_no_link(other_project.name)+ end+ end++ context "when not enabled for project" do+ before do+ searched_for_project.project_custom_field_project_mappings.destroy_all+ end++ it "does not find the project",+ skip: "TODO: this requires an available custom fields sql+ and it cannot be implemented in a simple way" do+ expect(page)+ .to have_no_link(searched_for_project.name)++ expect(page)+ .to have_no_link(other_project.name)+ end+ end+ endendend