Feature #6118 » rm6118-add_parent_issue_id_filter_to_issue_query-trunk_r13697.diff
| app/models/issue_query.rb | ||
|---|---|---|
|
:values => categories.collect{|s| [s.name, s.id.to_s] }
|
||
|
end
|
||
|
add_available_filter "parent_id", :type => :integer, :label => 'field_parent_issue'
|
||
|
add_available_filter "subject", :type => :text
|
||
|
add_available_filter "created_on", :type => :date_past
|
||
|
add_available_filter "updated_on", :type => :date_past
|
||
| test/unit/query_test.rb | ||
|---|---|---|
|
assert_equal [issue1], find_issues_with_query(query)
|
||
|
end
|
||
|
def test_filter_on_parent_task_id
|
||
|
user = User.find(2)
|
||
|
User.current = user
|
||
|
Issue.delete_all
|
||
|
iparent = Issue.generate!(:subject => 'Parent')
|
||
|
ichild1 = Issue.generate!(:project => iparent.project, :subject => 'Child1', :parent_issue_id => iparent.id)
|
||
|
ichild2 = Issue.generate!(:project => iparent.project, :subject => 'Child2', :parent_issue_id => iparent.id)
|
||
|
igchild = Issue.generate!(:project => iparent.project, :subject => 'Grand child', :parent_issue_id => ichild2.id)
|
||
|
query = IssueQuery.new(:name => '_')
|
||
|
# check if the filter is available for issue queries
|
||
|
assert query.available_filters.key?('parent_id')
|
||
|
# add the filter using the equal operator
|
||
|
query.add_filter('parent_id', '=', ["#{iparent.id}"])
|
||
|
issues = find_issues_with_query(query)
|
||
|
assert_equal 2, issues.size
|
||
|
# test the filter using the greater-or-equal operator
|
||
|
query = IssueQuery.new(:name => '_')
|
||
|
query.add_filter('parent_id', '>=', ["#{iparent.id}"])
|
||
|
issues = find_issues_with_query(query)
|
||
|
assert_equal 3, issues.size
|
||
|
# test the filter using the less-or-equal operator
|
||
|
query = IssueQuery.new(:name => '_')
|
||
|
query.add_filter('parent_id', '<=', ["#{iparent.id}"])
|
||
|
issues = find_issues_with_query(query)
|
||
|
assert_equal 2, issues.size
|
||
|
# test the filter using the between operator
|
||
|
query = IssueQuery.new(:name => '_')
|
||
|
query.add_filter('parent_id', '><', ["#{ichild2.id}", "#{igchild.id}"])
|
||
|
issues = find_issues_with_query(query)
|
||
|
assert_equal 1, issues.size
|
||
|
# test the filter using the none operator
|
||
|
query = IssueQuery.new(:name => '_')
|
||
|
query.add_filter('parent_id', '!*')
|
||
|
issues = find_issues_with_query(query)
|
||
|
assert_equal 1, issues.size
|
||
|
# test the filter using the any operator
|
||
|
query = IssueQuery.new(:name => '_')
|
||
|
query.add_filter('parent_id', '*')
|
||
|
issues = find_issues_with_query(query)
|
||
|
assert_equal 3, issues.size
|
||
|
ensure
|
||
|
Issue.delete_all
|
||
|
User.current = nil
|
||
|
end
|
||
|
def test_statement_should_be_nil_with_no_filters
|
||
|
q = IssueQuery.new(:name => '_')
|
||
|
q.filters = {}
|
||
- « Previous
- 1
- 2
- Next »