summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-05-11 02:08:41 +0000
committerGo MAEDA <maeda@farend.jp>2023-05-11 02:08:41 +0000
commit2caf5eaf973f82d3a9177f63378a642aec8b7d3b (patch)
treefce2bf5a112d3850ad4b6145aa02ae435431823e /test
parent8e170b1ec2f29666aea0166c9bad5575cf5eacce (diff)
downloadredmine-2caf5eaf973f82d3a9177f63378a642aec8b7d3b.tar.gz
redmine-2caf5eaf973f82d3a9177f63378a642aec8b7d3b.zip
New issues filter operators "has been", "has never been", and "changed from" (#38527).
Patch by Go MAEDA. git-svn-id: https://svn.redmine.org/redmine/trunk@22240 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/query_test.rb67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 6087616b0..8c5b5e1c8 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -797,6 +797,73 @@ class QueryTest < ActiveSupport::TestCase
assert_equal [2, 14], result.map(&:id).sort
end
+ def test_operator_changed_from
+ User.current = User.find(1)
+ issue1 = Issue.find(2)
+ issue1.init_journal(User.current)
+ issue1.update(status_id: 1) # Assigned (2) -> New
+ issue2 = Issue.find(8)
+ issue2.init_journal(User.current)
+ issue2.update(status_id: 2) # Closed (5) -> Assigned
+
+ query = IssueQuery.new(
+ :name => '_',
+ :filters => {
+ 'status_id' => {
+ :operator => 'cf',
+ :values => [2, 5] # Assigned, Closed
+ }
+ }
+ )
+ result = find_issues_with_query(query)
+ assert_equal(
+ [[2, 'New'], [8, 'Assigned']],
+ result.sort_by(&:id).map {|issue| [issue.id, issue.status.name]}
+ )
+ end
+
+ def test_operator_has_been
+ User.current = User.find(1)
+ issue = Issue.find(8)
+ issue.init_journal(User.current)
+ issue.update(status_id: 2) # Closed (5) -> Assigned
+
+ query = IssueQuery.new(
+ :name => '_',
+ :filters => {
+ 'status_id' => {
+ :operator => 'ev',
+ :values => [5] # Closed
+ }
+ }
+ )
+ result = find_issues_with_query(query)
+ assert_equal(
+ [[8, 'Assigned'], [11, 'Closed'], [12, 'Closed']],
+ result.sort_by(&:id).map {|issue| [issue.id, issue.status.name]}
+ )
+ end
+
+ def test_operator_has_never_been
+ User.current = User.find(1)
+ issue = Issue.find(8)
+ issue.init_journal(User.current)
+ issue.update(status_id: 2) # Closed (5) -> Assigned
+
+ query = IssueQuery.new(
+ :name => '_',
+ :filters => {
+ 'status_id' => {
+ :operator => '!ev',
+ :values => [5] # Closed
+ }
+ }
+ )
+ result = find_issues_with_query(query)
+ expected = Issue.all.order(:id).ids - [8, 11, 12]
+ assert_equal expected, result.map(&:id).sort
+ end
+
def test_range_for_this_week_with_week_starting_on_monday
I18n.locale = :fr
assert_equal '1', I18n.t(:general_first_day_of_week)