From e50190a82a5b6a066a3fadfdebf9df6e268719ad Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Sat, 19 Mar 2022 10:14:29 +0000 Subject: Automatically add the user to the watchers list after contributing to an issue (#4347). User can enable/disable this feature from My Account. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Takenori TAKAKI and Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@21469 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/unit/journal_test.rb | 22 ++++++++++++++++++++++ test/unit/user_preference_test.rb | 5 +++++ 2 files changed, 27 insertions(+) (limited to 'test') 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" -- cgit v1.2.3