]> source.dussan.org Git - redmine.git/commitdiff
Adds all/none operators to text custom field filters (#9790).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 12 May 2012 12:23:20 +0000 (12:23 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 12 May 2012 12:23:20 +0000 (12:23 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9671 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/query.rb
test/fixtures/custom_fields.yml
test/unit/query_test.rb

index 3b1150803dd785f1d0f69f0470add8a17f6f6c5e..9e2254f6010e4f361e2a47d5cb7b2fbb13e1816e 100644 (file)
@@ -126,8 +126,8 @@ class Query < ActiveRecord::Base
                                  :list_subprojects => [ "*", "!*", "=" ],
                                  :date => [ "=", ">=", "<=", "><", "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-", "!*", "*" ],
                                  :date_past => [ "=", ">=", "<=", "><", ">t-", "<t-", "t-", "t", "w", "!*", "*" ],
-                                 :string => [ "=", "~", "!", "!~" ],
-                                 :text => [  "~", "!~" ],
+                                 :string => [ "=", "~", "!", "!~", "!*", "*" ],
+                                 :text => [  "~", "!~", "!*", "*" ],
                                  :integer => [ "=", ">=", "<=", "><", "!*", "*" ],
                                  :float => [ "=", ">=", "<=", "><", "!*", "*" ] }
 
index e114ffa00fdcdfa841902d4be4bb048eba7b7377..4052228ced96d8befdbf8b96a086e2fb6adaf455 100644 (file)
@@ -21,6 +21,7 @@ custom_fields_002:
   min_length: 1
   regexp: ""
   is_for_all: true
+  is_filter: true
   type: IssueCustomField
   max_length: 100
   possible_values: ""
index 95dd12f1af9bb0eaa392ee1da4f86f49c5523f1f..c1eadcf0c260c0369530c15ebe056efacb4a40fa 100644 (file)
@@ -112,6 +112,15 @@ class QueryTest < ActiveSupport::TestCase
     assert issues.all? {|i| i.start_date.nil?}
   end
 
+  def test_operator_none_for_string_custom_field
+    query = Query.new(:project => Project.find(1), :name => '_')
+    query.add_filter('cf_2', '!*', [''])
+    assert query.has_filter?('cf_2')
+    issues = find_issues_with_query(query)
+    assert !issues.empty?
+    assert issues.all? {|i| i.custom_field_value(2).blank?}
+  end
+
   def test_operator_all
     query = Query.new(:project => Project.find(1), :name => '_')
     query.add_filter('fixed_version_id', '*', [''])
@@ -129,6 +138,15 @@ class QueryTest < ActiveSupport::TestCase
     assert issues.all? {|i| i.start_date.present?}
   end
 
+  def test_operator_all_for_string_custom_field
+    query = Query.new(:project => Project.find(1), :name => '_')
+    query.add_filter('cf_2', '*', [''])
+    assert query.has_filter?('cf_2')
+    issues = find_issues_with_query(query)
+    assert !issues.empty?
+    assert issues.all? {|i| i.custom_field_value(2).present?}
+  end
+
   def test_numeric_filter_should_not_accept_non_numeric_values
     query = Query.new(:name => '_')
     query.add_filter('estimated_hours', '=', ['a'])