Issue 2818 - When I comment a story, I should be "Involved" by the story
parent
f73f30e6b9
commit
4480cb474e
|
@ -123,6 +123,9 @@ def analize_object_for_watchers(obj:object, history:object):
|
||||||
for user in data["mentions"]:
|
for user in data["mentions"]:
|
||||||
obj.watchers.add(user)
|
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):
|
def _filter_by_permissions(obj, user):
|
||||||
UserStory = apps.get_model("userstories", "UserStory")
|
UserStory = apps.get_model("userstories", "UserStory")
|
||||||
|
|
|
@ -100,6 +100,36 @@ def test_analize_object_for_watchers():
|
||||||
assert issue.watchers.add.call_count == 2
|
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():
|
def test_users_to_notify():
|
||||||
project = f.ProjectFactory.create()
|
project = f.ProjectFactory.create()
|
||||||
role1 = f.RoleFactory.create(project=project, permissions=['view_issues'])
|
role1 = f.RoleFactory.create(project=project, permissions=['view_issues'])
|
||||||
|
|
Loading…
Reference in New Issue