]> source.dussan.org Git - redmine.git/commitdiff
Merged r16504 (#25478).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 8 Apr 2017 07:37:37 +0000 (07:37 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 8 Apr 2017 07:37:37 +0000 (07:37 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@16521 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue_query.rb
test/unit/query_test.rb

index 42d6df40fa70c5e859b86dac4f0f92a6eb707830..417b98b2a78d402ab473efc27c55aea76a9c6295 100644 (file)
@@ -550,7 +550,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
index 206677c26221cb82801931bc7daba60760e95353..9e4c76417f68515376e60257f0dcfa4f1cffc314 100644 (file)
@@ -897,7 +897,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))
@@ -911,6 +911,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))