From 47884d21fe6984917caae7d1f767cee814a20bff Mon Sep 17 00:00:00 2001 From: Kevin Fischer Date: Thu, 30 Mar 2017 18:54:40 +0900 Subject: Add test --- test/unit/query_test.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index 885c30caa..09d9508d6 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -1100,7 +1100,7 @@ class QueryTest < ActiveSupport::TestCase assert_include 2, ids end - def test_filter_on_relations_with_no_open_issues + def test_filter_on_blocked_by_no_open_issues IssueRelation.delete_all # Issue 1 is blocked by 8, which is closed IssueRelation.create!(:relation_type => "blocked", :issue_from => Issue.find(1), :issue_to => Issue.find(8)) @@ -1114,6 +1114,20 @@ class QueryTest < ActiveSupport::TestCase assert_include 1, ids end + def test_filter_on_related_with_no_open_issues + IssueRelation.delete_all + # Issue 1 is blocked by 8, which is closed + IssueRelation.create!(relation_type: 'relates', issue_from: Issue.find(1), issue_to: Issue.find(8)) + # Issue 2 is blocked by 3, which is open + IssueRelation.create!(relation_type: 'relates', issue_from: Issue.find(2), issue_to: Issue.find(3)) + + query = IssueQuery.new(:name => '_') + query.filters = { 'relates' => { operator: '!o', values: [''] } } + ids = find_issues_with_query(query).map(&:id) + assert_equal [], ids & [2] + assert_include 1, ids + end + def test_filter_on_relations_with_no_issues IssueRelation.delete_all IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Issue.find(2)) -- 2.11.0 (Apple Git-81) From 09b6c074c30cff1e21e57c67c31b56ee984f6e8f Mon Sep 17 00:00:00 2001 From: Kevin Fischer Date: Thu, 30 Mar 2017 18:54:47 +0900 Subject: Fix bug --- app/models/issue_query.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 9f3bf290d..18283711a 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -553,7 +553,7 @@ class IssueQuery < Query if relation_options[:sym] == field && !options[:reverse] sqls = [sql, sql_for_relations(field, operator, value, :reverse => true)] - sql = sqls.join(["!", "!*", "!p"].include?(operator) ? " AND " : " OR ") + sql = sqls.join(["!", "!*", "!p", '!o'].include?(operator) ? " AND " : " OR ") end "(#{sql})" end -- 2.11.0 (Apple Git-81)