]> source.dussan.org Git - redmine.git/commitdiff
Merged r20990 from trunk to 4.1-stable (#35201).
authorGo MAEDA <maeda@farend.jp>
Fri, 7 May 2021 04:50:06 +0000 (04:50 +0000)
committerGo MAEDA <maeda@farend.jp>
Fri, 7 May 2021 04:50:06 +0000 (04:50 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@20992 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/query.rb
test/unit/query_test.rb

index 152b11cf16dedf6efeb3de83ff553861337164c8..9d5a5c78d8c162f104e2fe0846e2cb64c9760f35 100644 (file)
@@ -501,7 +501,7 @@ class Query < ActiveRecord::Base
       if has_filter?(field) || !filter.remote
         options[:values] = filter.values
         if options[:values] && values_for(field)
-          missing = Array(values_for(field)).select(&:present?) - options[:values].map(&:last)
+          missing = Array(values_for(field)).select(&:present?) - options[:values].map{|v| v[1]}
           if missing.any? && respond_to?(method = "find_#{field}_filter_values")
             options[:values] += send(method, missing)
           end
index d080ad84658d60dcfb13a4262062848869c144a0..92fb1f1790b2a76162174e28df8155133ec6235e 100644 (file)
@@ -1451,6 +1451,19 @@ class QueryTest < ActiveSupport::TestCase
     end
   end
 
+  def test_available_filters_as_json_should_not_include_duplicate_assigned_to_id_values
+    set_language_if_valid 'en'
+    user = User.find_by_login 'dlopper'
+    with_current_user User.find(1) do
+      q = IssueQuery.new
+      q.filters = {"assigned_to_id" => {:operator => '=', :values => user.id.to_s}}
+
+      filters = q.available_filters_as_json
+      assert_not_include [user.name, user.id.to_s], filters['assigned_to_id']['values']
+      assert_include [user.name, user.id.to_s, 'active'], filters['assigned_to_id']['values']
+    end
+  end
+
   def test_available_filters_as_json_should_include_missing_author_id_values
     user = User.generate!
     with_current_user User.find(1) do