Skip to content

Commit

Permalink
Issue 2818 - When I comment a story, I should be "Involved" by the story
Browse files Browse the repository at this point in the history
  • Loading branch information
superalex committed Jun 25, 2015
1 parent f73f30e commit 4480cb4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions taiga/projects/notifications/services.py
Expand Up @@ -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")
Expand Down
30 changes: 30 additions & 0 deletions tests/integration/test_notifications.py
Expand Up @@ -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'])
Expand Down

0 comments on commit 4480cb4

Please sign in to comment.