summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-02-26 07:46:35 +0000
committerGo MAEDA <maeda@farend.jp>2023-02-26 07:46:35 +0000
commit9a625f261039e523b8aab77ad2017d96abd4e08c (patch)
tree5c58d7e9c5de71e1fcf936aeed32672be816c6f5 /test
parent49bfa116a157877ef804bcf5354dea99f5c361ab (diff)
downloadredmine-9a625f261039e523b8aab77ad2017d96abd4e08c.tar.gz
redmine-9a625f261039e523b8aab77ad2017d96abd4e08c.zip
Auto watch issues on issue creation (#38238).
Patch by Felix Schäfer. git-svn-id: https://svn.redmine.org/redmine/trunk@22115 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/issue_test.rb34
-rw-r--r--test/unit/user_preference_test.rb2
2 files changed, 35 insertions, 1 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 14dca00e3..5795d2bb1 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -3445,6 +3445,40 @@ class IssueTest < ActiveSupport::TestCase
assert_equal [5], issue2.filter_projects_scope('').ids.sort
end
+ def test_create_should_add_watcher
+ user = User.first
+ user.pref.auto_watch_on=['issue_created']
+ user.pref.save
+ issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => user.id, :subject => 'test_create_should_add_watcher')
+
+ assert_difference 'Watcher.count', 1 do
+ assert_equal true, issue.save
+ end
+ end
+
+ def test_create_should_add_author_watcher_only_once
+ user = User.first
+ user.pref.auto_watch_on=['issue_created']
+ user.pref.save
+ issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => user.id, :subject => 'test_create_should_add_watcher')
+ issue.watcher_user_ids = [user.id]
+
+ assert_difference 'Watcher.count', 1 do
+ assert_equal true, issue.save
+ end
+ end
+
+ def test_create_should_not_add_watcher
+ user = User.first
+ user.pref.auto_watch_on=[]
+ user.pref.save
+ issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => user.id, :subject => 'test_create_should_not_add_watcher')
+
+ assert_no_difference 'Watcher.count' do
+ assert_equal true, issue.save
+ end
+ end
+
def test_like_should_escape_query
issue = Issue.generate!(:subject => "asdf")
r = Issue.like('as_f')
diff --git a/test/unit/user_preference_test.rb b/test/unit/user_preference_test.rb
index 67157d5a2..6a74dde0a 100644
--- a/test/unit/user_preference_test.rb
+++ b/test/unit/user_preference_test.rb
@@ -59,7 +59,7 @@ class UserPreferenceTest < ActiveSupport::TestCase
def test_auto_watch_on_should_default_to_setting
preference = UserPreference.new
- assert_equal ['issue_contributed_to'], preference.auto_watch_on
+ assert_equal %w[issue_created issue_contributed_to], preference.auto_watch_on
end
def test_create