diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 68ce1c104..cd363b5c8 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -791,8 +791,14 @@ class IssueQuery < Query projects = nil end + is_all_words = + case operator + when '~' then true + when '|~', '!~' then false + end + fetcher = Redmine::Search::Fetcher.new( - question, User.current, ['issue'], projects, all_words: (operator != '!~'), attachments: '0' + question, User.current, ['issue'], projects, all_words: is_all_words, attachments: '0' ) ids = fetcher.result_ids.map(&:last) if ids.present? diff --git a/app/models/query.rb b/app/models/query.rb index 289d683f6..1a952cd54 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -306,6 +306,7 @@ class Query < ActiveRecord::Base "t-" => :label_ago, "~" => :label_contains, "!~" => :label_not_contains, + "|~" => :label_contains_any_of, "^" => :label_starts_with, "$" => :label_ends_with, "=p" => :label_any_issues_in_project, @@ -325,7 +326,7 @@ class Query < ActiveRecord::Base :date_past => [ "=", ">=", "<=", "><", ">t-", " [ "~", "=", "!~", "!", "^", "$", "!*", "*" ], :text => [ "~", "!~", "^", "$", "!*", "*" ], - :search => [ "~", "!~" ], + :search => [ "~", "|~", "!~" ], :integer => [ "=", ">=", "<=", "><", "!*", "*" ], :float => [ "=", ">=", "<=", "><", "!*", "*" ], :relation => ["=", "!", "=p", "=!p", "!p", "*o", "!o", "!*", "*"], diff --git a/config/locales/en.yml b/config/locales/en.yml index 8c9edb8bc..6b7d0834a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -810,6 +810,7 @@ en: label_more_than_ago: more than days ago label_ago: days ago label_contains: contains + label_contains_any_of: contains any of label_not_contains: doesn't contain label_starts_with: starts with label_ends_with: ends with diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index 607679e83..fbfcdff7d 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -874,6 +874,21 @@ class QueryTest < ActiveSupport::TestCase assert_equal [2], result.map(&:id) end + def test_filter_any_searchable_with_contains_any_operator + User.current = User.find(1) + query = IssueQuery.new( + :name => '_', + :filters => { + 'any_searchable' => { + :operator => '|~', + :values => ['recipe categories'] + } + } + ) + result = find_issues_with_query(query) + assert_equal [1, 2, 3], result.map(&:id) + end + def test_filter_any_searchable_with_multiple_words_negative User.current = User.find(1)