From: Go MAEDA Date: Mon, 1 May 2023 14:33:22 +0000 (+0000) Subject: Make the "Any searchable text" filter search only open issues when the status filter... X-Git-Tag: 5.1.0~144 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5352225a8ca5bab25a51c3f4169a98cda364fc86;p=redmine.git Make the "Any searchable text" filter search only open issues when the status filter is set to "open" (#38402). git-svn-id: https://svn.redmine.org/redmine/trunk@22221 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 94d753603..e573f8782 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -805,8 +805,11 @@ class IssueQuery < Query when '*~', '!~' then false end + is_open_issues = has_filter?('status_id') && operator_for('status_id') == 'o' + fetcher = Redmine::Search::Fetcher.new( - question, User.current, ['issue'], projects, all_words: is_all_words, attachments: '0' + question, User.current, ['issue'], projects, + all_words: is_all_words, open_issues: is_open_issues, attachments: '0' ) ids = fetcher.result_ids.map(&:last) if ids.present? diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index 283bb2e16..6087616b0 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -1071,6 +1071,21 @@ class QueryTest < ActiveSupport::TestCase result.each {|issue| assert_includes [1, 5], issue.project_id} end + def test_filter_any_searchable_with_open_issues_should_search_only_open_issues + User.current = User.find(1) + query = IssueQuery.new( + :name => '_', + :filters => { + 'status_id' => {:operator => 'o'} + } + ) + + result = query.sql_for_any_searchable_field(nil, '~', ['issue']) + assert_match /issues.id IN \([\d,]+\)/, result + ids = result.scan(/\d+/).map(&:to_i).sort + assert_equal [4, 5, 6, 7, 9, 10, 13, 14], ids + end + def test_filter_updated_by user = User.generate! Journal.create!(:user_id => user.id, :journalized => Issue.find(2), :notes => 'Notes')