848 |
848 |
assert_equal [issue1], find_issues_with_query(query)
|
849 |
849 |
end
|
850 |
850 |
|
|
851 |
def test_filter_on_parent_task_id
|
|
852 |
user = User.find(2)
|
|
853 |
User.current = user
|
|
854 |
|
|
855 |
Issue.delete_all
|
|
856 |
|
|
857 |
iparent = Issue.generate!(:subject => 'Parent')
|
|
858 |
ichild1 = Issue.generate!(:project => iparent.project, :subject => 'Child1', :parent_issue_id => iparent.id)
|
|
859 |
ichild2 = Issue.generate!(:project => iparent.project, :subject => 'Child2', :parent_issue_id => iparent.id)
|
|
860 |
igchild = Issue.generate!(:project => iparent.project, :subject => 'Grand child', :parent_issue_id => ichild2.id)
|
|
861 |
|
|
862 |
query = IssueQuery.new(:name => '_')
|
|
863 |
|
|
864 |
# check if the filter is available for issue queries
|
|
865 |
assert query.available_filters.key?('parent_id')
|
|
866 |
|
|
867 |
# add the filter using the equal operator
|
|
868 |
query.add_filter('parent_id', '=', ["#{iparent.id}"])
|
|
869 |
|
|
870 |
issues = find_issues_with_query(query)
|
|
871 |
assert_equal 2, issues.size
|
|
872 |
|
|
873 |
# test the filter using the greater-or-equal operator
|
|
874 |
query = IssueQuery.new(:name => '_')
|
|
875 |
query.add_filter('parent_id', '>=', ["#{iparent.id}"])
|
|
876 |
|
|
877 |
issues = find_issues_with_query(query)
|
|
878 |
assert_equal 3, issues.size
|
|
879 |
|
|
880 |
# test the filter using the less-or-equal operator
|
|
881 |
query = IssueQuery.new(:name => '_')
|
|
882 |
query.add_filter('parent_id', '<=', ["#{iparent.id}"])
|
|
883 |
|
|
884 |
issues = find_issues_with_query(query)
|
|
885 |
assert_equal 2, issues.size
|
|
886 |
|
|
887 |
# test the filter using the between operator
|
|
888 |
query = IssueQuery.new(:name => '_')
|
|
889 |
query.add_filter('parent_id', '><', ["#{ichild2.id}", "#{igchild.id}"])
|
|
890 |
|
|
891 |
issues = find_issues_with_query(query)
|
|
892 |
assert_equal 1, issues.size
|
|
893 |
|
|
894 |
# test the filter using the none operator
|
|
895 |
query = IssueQuery.new(:name => '_')
|
|
896 |
query.add_filter('parent_id', '!*')
|
|
897 |
|
|
898 |
issues = find_issues_with_query(query)
|
|
899 |
assert_equal 1, issues.size
|
|
900 |
|
|
901 |
# test the filter using the any operator
|
|
902 |
query = IssueQuery.new(:name => '_')
|
|
903 |
query.add_filter('parent_id', '*')
|
|
904 |
|
|
905 |
issues = find_issues_with_query(query)
|
|
906 |
assert_equal 3, issues.size
|
|
907 |
ensure
|
|
908 |
Issue.delete_all
|
|
909 |
User.current = nil
|
|
910 |
end
|
|
911 |
|
851 |
912 |
def test_statement_should_be_nil_with_no_filters
|
852 |
913 |
q = IssueQuery.new(:name => '_')
|
853 |
914 |
q.filters = {}
|