From 4480cb474ef240fd6f8ee153f97d4e46398c0da7 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Wed, 24 Jun 2015 14:10:50 +0200 Subject: [PATCH] Issue 2818 - When I comment a story, I should be "Involved" by the story --- taiga/projects/notifications/services.py | 3 +++ tests/integration/test_notifications.py | 30 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/taiga/projects/notifications/services.py b/taiga/projects/notifications/services.py index 67fb894a..75f7e48b 100644 --- a/taiga/projects/notifications/services.py +++ b/taiga/projects/notifications/services.py @@ -123,6 +123,9 @@ def analize_object_for_watchers(obj:object, history:object): for user in data["mentions"]: obj.watchers.add(user) + # Adding the person who edited the object to the watchers + if history.comment and not history.owner.is_system: + obj.watchers.add(history.owner) def _filter_by_permissions(obj, user): UserStory = apps.get_model("userstories", "UserStory") diff --git a/tests/integration/test_notifications.py b/tests/integration/test_notifications.py index 13087254..a5a9847c 100644 --- a/tests/integration/test_notifications.py +++ b/tests/integration/test_notifications.py @@ -100,6 +100,36 @@ def test_analize_object_for_watchers(): assert issue.watchers.add.call_count == 2 +def test_analize_object_for_watchers_adding_owner_non_empty_comment(): + user1 = f.UserFactory.create() + + issue = MagicMock() + issue.description = "Foo" + issue.content = "" + + history = MagicMock() + history.comment = "Comment" + history.owner = user1 + + services.analize_object_for_watchers(issue, history) + assert issue.watchers.add.call_count == 1 + + +def test_analize_object_for_watchers_no_adding_owner_empty_comment(): + user1 = f.UserFactory.create() + + issue = MagicMock() + issue.description = "Foo" + issue.content = "" + + history = MagicMock() + history.comment = "" + history.owner = user1 + + services.analize_object_for_watchers(issue, history) + assert issue.watchers.add.call_count == 0 + + def test_users_to_notify(): project = f.ProjectFactory.create() role1 = f.RoleFactory.create(project=project, permissions=['view_issues'])