summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/issue_query.rb2
-rw-r--r--test/unit/query_test.rb49
2 files changed, 48 insertions, 3 deletions
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb
index 1c60c6b61..e45548121 100644
--- a/app/models/issue_query.rb
+++ b/app/models/issue_query.rb
@@ -799,7 +799,7 @@ class IssueQuery < Query
sw = operator == '!~' ? 'NOT' : ''
"#{Issue.table_name}.id #{sw} IN (#{ids.join(',')})"
else
- '1=0'
+ operator == '!~' ? '1=1' : '1=0'
end
end
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 2b02a1e07..2bbf91198 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -844,7 +844,7 @@ class QueryTest < ActiveSupport::TestCase
assert_equal [1, 3], find_issues_with_query(query).map(&:id).sort
end
- def test_fileter_any_searchable
+ def test_filter_any_searchable
User.current = User.find(1)
query = IssueQuery.new(
:name => '_',
@@ -859,7 +859,52 @@ class QueryTest < ActiveSupport::TestCase
assert_equal [1, 2, 3], result.map(&:id).sort
end
- def test_fileter_any_searchable_should_search_searchable_custom_fields
+ def test_filter_any_searchable_no_matches
+ User.current = User.find(1)
+ query = IssueQuery.new(
+ :name => '_',
+ :filters => {
+ 'any_searchable' => {
+ :operator => '~',
+ :values => ['SomethingThatDoesNotExist']
+ }
+ }
+ )
+ result = find_issues_with_query(query)
+ assert_empty result.map(&:id)
+ end
+
+ def test_filter_any_searchable_negative
+ User.current = User.find(1)
+ query = IssueQuery.new(
+ :name => '_',
+ :filters => {
+ 'any_searchable' => {
+ :operator => '!~',
+ :values => ['recipe']
+ }
+ }
+ )
+ result = find_issues_with_query(query)
+ assert_not_includes [1, 2, 3], result.map(&:id)
+ end
+
+ def test_filter_any_searchable_negative_no_matches
+ User.current = User.find(1)
+ query = IssueQuery.new(
+ :name => '_',
+ :filters => {
+ 'any_searchable' => {
+ :operator => '!~',
+ :values => ['SomethingThatDoesNotExist']
+ }
+ }
+ )
+ result = find_issues_with_query(query)
+ assert_not_empty result.map(&:id)
+ end
+
+ def test_filter_any_searchable_should_search_searchable_custom_fields
User.current = User.find(1)
query = IssueQuery.new(
:name => '_',