]> source.dussan.org Git - redmine.git/commitdiff
Merged r22478 to r22479from trunk to 5.1-stable (#39714).
authorMarius Balteanu <marius.balteanu@zitec.com>
Sun, 26 Nov 2023 13:57:25 +0000 (13:57 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Sun, 26 Nov 2023 13:57:25 +0000 (13:57 +0000)
git-svn-id: https://svn.redmine.org/redmine/branches/5.1-stable@22481 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/queries_helper.rb
test/helpers/queries_helper_test.rb

index b90f86457a632867002607ccaf7988fb7d00a128..d2505ff6fc78d26e8dff4ac3968e6408c7054530 100644 (file)
@@ -26,15 +26,15 @@ module QueriesHelper
     ungrouped = []
     grouped = {label_string: [], label_date: [], label_time_tracking: [], label_attachment: []}
     query.available_filters.map do |field, field_options|
-      if field =~ /^(.+)\./
+      if /^cf_\d+\./.match?(field)
+        group = (field_options[:through] || field_options[:field]).try(:name)
+      elsif field =~ /^(.+)\./
         # association filters
         group = "field_#{$1}".to_sym
       elsif field_options[:type] == :relation
         group = :label_relations
       elsif field_options[:type] == :tree
         group = query.is_a?(IssueQuery) ? :label_relations : nil
-      elsif /^cf_\d+\./.match?(field)
-        group = (field_options[:through] || field_options[:field]).try(:name)
       elsif %w(member_of_group assigned_to_role).include?(field)
         group = :field_assigned_to
       elsif field_options[:type] == :date_past || field_options[:type] == :date
index b2943bd036b89243504bf42df0b665024dfd3746..8c2fd1cb34766befbbbca81dff920b79e4f9280f 100644 (file)
@@ -105,4 +105,16 @@ class QueriesHelperTest < Redmine::HelperTest
       assert_include "Non", csv
     end
   end
+
+  def test_filters_options_for_select_should_group_custom_field_relations
+    i_cf = IssueCustomField.generate!(field_format: 'user', name: 'User', is_for_all: true, trackers: Tracker.all, is_filter: true)
+    u_cf = UserCustomField.find(4)
+    u_cf.is_filter = true
+    u_cf.save
+
+    options = filters_options_for_select(IssueQuery.new)
+
+    assert_select_in options, 'option[value=?]', "cf_#{i_cf.id}.cf_#{u_cf.id}", text: "User's Phone number"
+    assert_select_in options, 'optgroup[label=?]', 'User', 1
+  end
 end