summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2022-03-19 10:14:29 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2022-03-19 10:14:29 +0000
commite50190a82a5b6a066a3fadfdebf9df6e268719ad (patch)
treec49f3341b96612314a1f0e238102cce24f1aaaa7 /test
parent23874fa913c62f7da23f2d1fab6e5e1a445ae290 (diff)
downloadredmine-e50190a82a5b6a066a3fadfdebf9df6e268719ad.tar.gz
redmine-e50190a82a5b6a066a3fadfdebf9df6e268719ad.zip
Automatically add the user to the watchers list after contributing to an issue (#4347). User can enable/disable this feature from My Account.
Patch by Takenori TAKAKI and Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@21469 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/journal_test.rb22
-rw-r--r--test/unit/user_preference_test.rb5
2 files changed, 27 insertions, 0 deletions
diff --git a/test/unit/journal_test.rb b/test/unit/journal_test.rb
index f9c269291..cf86a7990 100644
--- a/test/unit/journal_test.rb
+++ b/test/unit/journal_test.rb
@@ -120,6 +120,28 @@ class JournalTest < ActiveSupport::TestCase
end
end
+ def test_create_should_add_wacher
+ user = User.first
+ user.pref.auto_watch_on=['issue_contributed_to']
+ user.save
+ journal = Journal.new(:journalized => Issue.first, :notes => 'notes', :user => user)
+
+ assert_difference 'Watcher.count', 1 do
+ assert_equal true, journal.save
+ end
+ end
+
+ def test_create_should_not_add_watcher
+ user = User.first
+ user.pref.auto_watch_on=[]
+ user.save
+ journal = Journal.new(:journalized => Issue.first, :notes => 'notes', :user => user)
+
+ assert_no_difference 'Watcher.count' do
+ assert_equal true, journal.save
+ end
+ end
+
def test_visible_scope_for_anonymous
# Anonymous user should see issues of public projects only
journals = Journal.visible(User.anonymous).to_a
diff --git a/test/unit/user_preference_test.rb b/test/unit/user_preference_test.rb
index 9ac213b5f..4ca79400e 100644
--- a/test/unit/user_preference_test.rb
+++ b/test/unit/user_preference_test.rb
@@ -57,6 +57,11 @@ class UserPreferenceTest < ActiveSupport::TestCase
end
end
+ def test_auto_watch_on_should_default_to_setting
+ preference = UserPreference.new
+ assert_equal ['issue_contributed_to'], preference.auto_watch_on
+ end
+
def test_create
user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
user.login = "newuser"