summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2021-04-21 07:01:02 +0000
committerGo MAEDA <maeda@farend.jp>2021-04-21 07:01:02 +0000
commit7ab1a667a9226c3453166bcdad7edb906ea410df (patch)
tree654fe0eb561956bbfb16a3934c67e1ede9f90d61 /test/unit
parent2be94d1ea1c3cd24e1d59248c7f7916f5d7bc476 (diff)
downloadredmine-7ab1a667a9226c3453166bcdad7edb906ea410df.tar.gz
redmine-7ab1a667a9226c3453166bcdad7edb906ea410df.zip
Filter issues by notes (#5893).
Patch by Yuichi HARADA. git-svn-id: http://svn.redmine.org/redmine/trunk@20955 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/query_test.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 75efaae8a..118cb3dc1 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -803,6 +803,47 @@ class QueryTest < ActiveSupport::TestCase
end
end
+ def test_filter_notes
+ user = User.generate!
+ Journal.create!(:user_id => user.id, :journalized => Issue.find(2), :notes => 'Notes.')
+ Journal.create!(:user_id => user.id, :journalized => Issue.find(3), :notes => 'Notes.')
+
+ issue_journals = Issue.find(1).journals.sort
+ assert_equal ['Journal notes', 'Some notes with Redmine links: #2, r2.'], issue_journals.map(&:notes)
+ assert_equal [false, false], issue_journals.map(&:private_notes)
+
+ query = IssueQuery.new(:name => '_')
+ filter_name = 'notes'
+ assert_include filter_name, query.available_filters.keys
+
+ {
+ '~' => [1, 2, 3],
+ '!~' => Issue.ids.sort - [1, 2, 3],
+ '^' => [2, 3],
+ '$' => [1],
+ }.each do |operator, expected|
+ query.filters = {filter_name => {:operator => operator, :values => ['Notes']}}
+ assert_equal expected, find_issues_with_query(query).map(&:id).sort
+ end
+ end
+
+ def test_filter_notes_should_ignore_private_notes_that_are_not_visible
+ user = User.generate!
+ Journal.create!(:user_id => user.id, :journalized => Issue.find(2), :notes => 'Notes.', :private_notes => true)
+ Journal.create!(:user_id => user.id, :journalized => Issue.find(3), :notes => 'Notes.')
+
+ issue_journals = Issue.find(1).journals.sort
+ assert_equal ['Journal notes', 'Some notes with Redmine links: #2, r2.'], issue_journals.map(&:notes)
+ assert_equal [false, false], issue_journals.map(&:private_notes)
+
+ query = IssueQuery.new(:name => '_')
+ filter_name = 'notes'
+ assert_include filter_name, query.available_filters.keys
+
+ query.filters = {filter_name => {:operator => '~', :values => ['Notes']}}
+ assert_equal [1, 3], find_issues_with_query(query).map(&:id).sort
+ end
+
def test_filter_updated_by
user = User.generate!
Journal.create!(:user_id => user.id, :journalized => Issue.find(2), :notes => 'Notes')