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
Filter out disabled project custom fields when searching for project custom fields
Dombi Attila94355defb59b
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 376f5ee1dd7..5ab1db7c347 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@@ -182,13 +182,24 @@ module Redmineif searchable_custom_field_ids.any?custom_field_condition =CustomValue.select("1").where(customized_type: name)- .joins("LEFT JOIN custom_options+ .joins(<<~SQL.squish)+ LEFT JOIN custom_optionsON custom_options.custom_field_id = custom_values.custom_field_id- AND custom_options.id::VARCHAR = custom_values.value")- .where("customized_id=#{table_name}.id")+ AND custom_options.id::VARCHAR = custom_values.value+ SQL+ .where(customized_id: arel_table[:id]).where(custom_field_id: searchable_custom_field_ids).where("(custom_values.value ILIKE ?) OR (custom_options.value ILIKE ?)")+ if name == "Project"+ # Filter out disabled project custom fields when searching for projects.+ custom_field_condition = custom_field_condition.joins(<<~SQL.squish)+ INNER JOIN project_custom_field_project_mappings+ ON project_custom_field_project_mappings.project_id = custom_values.customized_id+ AND project_custom_field_project_mappings.custom_field_id = custom_values.custom_field_id+ SQL+ end+"EXISTS ( #{custom_field_condition.to_sql} )"endenddiff --git a/spec/features/search/search_spec.rb b/spec/features/search/search_spec.rbindex 4cfe499fb82..c2cbb4f9f08 100644--- a/spec/features/search/search_spec.rb+++ b/spec/features/search/search_spec.rb@@ -546,9 +546,7 @@ RSpec.describe "Search", :js, with_settings: { per_page_options: "5" } dosearched_for_project.project_custom_field_project_mappings.destroy_allend- 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+ it "does not find the project" doexpect(page).to have_no_link(searched_for_project.name)