浏览代码

Adds all/none operators to text custom field filters (#9790).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9671 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/2.0.0
Jean-Philippe Lang 12 年前
父节点
当前提交
a99c61b471
共有 3 个文件被更改,包括 21 次插入2 次删除
  1. 2
    2
      app/models/query.rb
  2. 1
    0
      test/fixtures/custom_fields.yml
  3. 18
    0
      test/unit/query_test.rb

+ 2
- 2
app/models/query.rb 查看文件

@@ -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 => [ "=", ">=", "<=", "><", "!*", "*" ] }


+ 1
- 0
test/fixtures/custom_fields.yml 查看文件

@@ -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: ""

+ 18
- 0
test/unit/query_test.rb 查看文件

@@ -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'])

正在加载...
取消
保存