diff options
author | Go MAEDA <maeda@farend.jp> | 2023-04-05 23:36:18 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2023-04-05 23:36:18 +0000 |
commit | 972e51bc89d6043b987703364ce4726624da8e0e (patch) | |
tree | 657dcc6793928c81a50b3eef14b8ec382f3721a9 /test/unit/query_test.rb | |
parent | 27b8f57fd8c7e8b1279b483128edbdcc9723be49 (diff) | |
download | redmine-972e51bc89d6043b987703364ce4726624da8e0e.tar.gz redmine-972e51bc89d6043b987703364ce4726624da8e0e.zip |
Change the behavior of the "Any searchable text" filter from OR search to AND search (#38402).
Patch by Go MAEDA.
git-svn-id: https://svn.redmine.org/redmine/trunk@22169 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/query_test.rb')
-rw-r--r-- | test/unit/query_test.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index 2bbf91198..607679e83 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -859,6 +859,41 @@ class QueryTest < ActiveSupport::TestCase assert_equal [1, 2, 3], result.map(&:id).sort end + def test_filter_any_searchable_with_multiple_words + User.current = User.find(1) + query = IssueQuery.new( + :name => '_', + :filters => { + 'any_searchable' => { + :operator => '~', + :values => ['recipe categories'] + } + } + ) + result = find_issues_with_query(query) + assert_equal [2], result.map(&:id) + end + + def test_filter_any_searchable_with_multiple_words_negative + User.current = User.find(1) + + query_result_ids = ->(op, value) do + query = IssueQuery.new( + :name => '_', + :filters => {'any_searchable' => {:operator => op, :values => [value]}} + ) + find_issues_with_query(query).map(&:id).sort + end + + ids = query_result_ids.call('!~', 'recipe categories') + ids_word1 = query_result_ids.call('~', 'recipe') + ids_word2 = query_result_ids.call('~', 'categories') + + # Neither "recipe" nor "categories" are in the subject, description, + # notes, etc. + assert ids, Issue.ids.sort - ids_word1 - ids_word2 + end + def test_filter_any_searchable_no_matches User.current = User.find(1) query = IssueQuery.new( |