IssueActions: Add WEIGHT_CHANGED event

parent f274c8b1
Pipeline #36834433 passed with stage
in 31 seconds
......@@ -214,6 +214,10 @@ class GitLab(GitLabMixin, Hoster):
assignees = data['changes']['assignees']['current']
users = {user['username'] for user in assignees}
yield IssueActions.ASSIGNEES_CHANGED, [issue_obj, users]
elif (trigger_event == IssueActions.ATTRIBUTES_CHANGED and
'weight' in data['changes']):
weight_changes = data['changes']['weight']
yield IssueActions.WEIGHT_CHANGED, [issue_obj, weight_changes]
elif (trigger_event == IssueActions.ATTRIBUTES_CHANGED and
'labels' in data['changes']):
# labels are changed
......
......@@ -51,6 +51,8 @@ class IssueActions(Enum):
UNLABELED = 7
# When the assignees on an issue are changed.
ASSIGNEES_CHANGED = 8
# When the weight on an issue is changed.
WEIGHT_CHANGED = 9
class PipelineActions(Enum):
"""
......
......@@ -228,3 +228,12 @@ class GitLabWebhookTest(IGittTestCase):
self.assertEqual(event, IssueActions.ASSIGNEES_CHANGED)
self.assertIsInstance(obj[0], GitLabIssue)
self.assertEqual(obj[1], {'gitmate-bot'})
def test_issue_weight_changed(self):
data = self.default_data
data['object_attributes']['action'] = 'update'
data['changes'] = {'weight': {'previous': 2, 'current': 5}}
for event, obj in self.gl.handle_webhook('Issue Hook', data):
self.assertEqual(event, IssueActions.WEIGHT_CHANGED)
self.assertIsInstance(obj[0], GitLabIssue)
self.assertEqual(obj[1], {'previous': 2, 'current': 5})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment