Adds estimated hours to issue filters (#1678).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1696 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
9f92554319
commit
6ddea3396b
|
@ -88,7 +88,7 @@ class Query < ActiveRecord::Base
|
|||
:date_past => [ ">t-", "<t-", "t-", "t", "w" ],
|
||||
:string => [ "=", "~", "!", "!~" ],
|
||||
:text => [ "~", "!~" ],
|
||||
:integer => [ "=", ">=", "<=" ] }
|
||||
:integer => [ "=", ">=", "<=", "!*", "*" ] }
|
||||
|
||||
cattr_reader :operators_by_filter_type
|
||||
|
||||
|
@ -152,7 +152,8 @@ class Query < ActiveRecord::Base
|
|||
"updated_on" => { :type => :date_past, :order => 10 },
|
||||
"start_date" => { :type => :date, :order => 11 },
|
||||
"due_date" => { :type => :date, :order => 12 },
|
||||
"done_ratio" => { :type => :integer, :order => 13 }}
|
||||
"estimated_hours" => { :type => :integer, :order => 13 },
|
||||
"done_ratio" => { :type => :integer, :order => 14 }}
|
||||
|
||||
user_values = []
|
||||
user_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
|
||||
|
|
|
@ -26,11 +26,17 @@ class QueryTest < Test::Unit::TestCase
|
|||
assert !query.available_filters.has_key?('cf_3')
|
||||
end
|
||||
|
||||
def find_issues_with_query(query)
|
||||
Issue.find :all,
|
||||
:include => [ :assigned_to, :status, :tracker, :project, :priority ],
|
||||
:conditions => query.statement
|
||||
end
|
||||
|
||||
def test_query_with_multiple_custom_fields
|
||||
query = Query.find(1)
|
||||
assert query.valid?
|
||||
assert query.statement.include?("#{CustomValue.table_name}.value IN ('MySQL')")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
issues = find_issues_with_query(query)
|
||||
assert_equal 1, issues.length
|
||||
assert_equal Issue.find(3), issues.first
|
||||
end
|
||||
|
@ -41,7 +47,15 @@ class QueryTest < Test::Unit::TestCase
|
|||
query.add_filter('cf_1', '!*', [''])
|
||||
assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NULL")
|
||||
assert query.statement.include?("#{CustomValue.table_name}.value IS NULL OR #{CustomValue.table_name}.value = ''")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
def test_operator_none_for_integer
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('estimated_hours', '!*', [''])
|
||||
issues = find_issues_with_query(query)
|
||||
assert !issues.empty?
|
||||
assert issues.all? {|i| !i.estimated_hours}
|
||||
end
|
||||
|
||||
def test_operator_all
|
||||
|
@ -50,63 +64,63 @@ class QueryTest < Test::Unit::TestCase
|
|||
query.add_filter('cf_1', '*', [''])
|
||||
assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NOT NULL")
|
||||
assert query.statement.include?("#{CustomValue.table_name}.value IS NOT NULL AND #{CustomValue.table_name}.value <> ''")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
def test_operator_greater_than
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('done_ratio', '>=', ['40'])
|
||||
assert query.statement.include?("#{Issue.table_name}.done_ratio >= 40")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
def test_operator_in_more_than
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('due_date', '>t+', ['15'])
|
||||
assert query.statement.include?("#{Issue.table_name}.due_date >=")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
def test_operator_in_less_than
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('due_date', '<t+', ['15'])
|
||||
assert query.statement.include?("#{Issue.table_name}.due_date BETWEEN")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
def test_operator_today
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('due_date', 't', [''])
|
||||
assert query.statement.include?("#{Issue.table_name}.due_date BETWEEN")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
def test_operator_this_week_on_date
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('due_date', 'w', [''])
|
||||
assert query.statement.include?("#{Issue.table_name}.due_date BETWEEN")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
def test_operator_this_week_on_datetime
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('created_on', 'w', [''])
|
||||
assert query.statement.include?("#{Issue.table_name}.created_on BETWEEN")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
def test_operator_contains
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('subject', '~', ['string'])
|
||||
assert query.statement.include?("#{Issue.table_name}.subject LIKE '%string%'")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
def test_operator_does_not_contains
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('subject', '!~', ['string'])
|
||||
assert query.statement.include?("#{Issue.table_name}.subject NOT LIKE '%string%'")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
def test_default_columns
|
||||
|
|
Loading…
Reference in New Issue