Project

General

Profile

Defect #25478 » fix-filter-related-to-non-open.diff

Kevin Fischer, 2017-03-30 12:08

View differences:

test/unit/query_test.rb
1100 1100
    assert_include 2, ids
1101 1101
  end
1102 1102

  
1103
  def test_filter_on_relations_with_no_open_issues
1103
  def test_filter_on_blocked_by_no_open_issues
1104 1104
    IssueRelation.delete_all
1105 1105
    # Issue 1 is blocked by 8, which is closed
1106 1106
    IssueRelation.create!(:relation_type => "blocked", :issue_from => Issue.find(1), :issue_to => Issue.find(8))
......
1114 1114
    assert_include 1, ids
1115 1115
  end
1116 1116

  
1117
  def test_filter_on_related_with_no_open_issues
1118
    IssueRelation.delete_all
1119
    # Issue 1 is blocked by 8, which is closed
1120
    IssueRelation.create!(relation_type: 'relates', issue_from: Issue.find(1), issue_to: Issue.find(8))
1121
    # Issue 2 is blocked by 3, which is open
1122
    IssueRelation.create!(relation_type: 'relates', issue_from: Issue.find(2), issue_to: Issue.find(3))
1123

  
1124
    query = IssueQuery.new(:name => '_')
1125
    query.filters = { 'relates' => { operator: '!o', values: [''] } }
1126
    ids = find_issues_with_query(query).map(&:id)
1127
    assert_equal [], ids & [2]
1128
    assert_include 1, ids
1129
  end
1130

  
1117 1131
  def test_filter_on_relations_with_no_issues
1118 1132
    IssueRelation.delete_all
1119 1133
    IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Issue.find(2))
1120
- 
app/models/issue_query.rb
553 553

  
554 554
    if relation_options[:sym] == field && !options[:reverse]
555 555
      sqls = [sql, sql_for_relations(field, operator, value, :reverse => true)]
556
      sql = sqls.join(["!", "!*", "!p"].include?(operator) ? " AND " : " OR ")
556
      sql = sqls.join(["!", "!*", "!p", '!o'].include?(operator) ? " AND " : " OR ")
557 557
    end
558 558
    "(#{sql})"
559 559
  end
(1-1/5)