Allow multiple message actions on commit
parent
17ceab000c
commit
0e39653da9
|
@ -54,8 +54,7 @@ class PushEventHook(BaseEventHook):
|
||||||
return
|
return
|
||||||
|
|
||||||
p = re.compile("tg-(\d+) +#([-\w]+)")
|
p = re.compile("tg-(\d+) +#([-\w]+)")
|
||||||
m = p.search(message.lower())
|
for m in p.finditer(message.lower()):
|
||||||
if m:
|
|
||||||
ref = m.group(1)
|
ref = m.group(1)
|
||||||
status_slug = m.group(2)
|
status_slug = m.group(2)
|
||||||
self._change_status(ref, status_slug, bitbucket_user)
|
self._change_status(ref, status_slug, bitbucket_user)
|
||||||
|
|
|
@ -56,8 +56,7 @@ class PushEventHook(BaseEventHook):
|
||||||
return
|
return
|
||||||
|
|
||||||
p = re.compile("tg-(\d+) +#([-\w]+)")
|
p = re.compile("tg-(\d+) +#([-\w]+)")
|
||||||
m = p.search(message.lower())
|
for m in p.finditer(message.lower()):
|
||||||
if m:
|
|
||||||
ref = m.group(1)
|
ref = m.group(1)
|
||||||
status_slug = m.group(2)
|
status_slug = m.group(2)
|
||||||
self._change_status(ref, status_slug, github_user, commit)
|
self._change_status(ref, status_slug, github_user, commit)
|
||||||
|
|
|
@ -54,8 +54,7 @@ class PushEventHook(BaseEventHook):
|
||||||
return
|
return
|
||||||
|
|
||||||
p = re.compile("tg-(\d+) +#([-\w]+)")
|
p = re.compile("tg-(\d+) +#([-\w]+)")
|
||||||
m = p.search(message.lower())
|
for m in p.finditer(message.lower()):
|
||||||
if m:
|
|
||||||
ref = m.group(1)
|
ref = m.group(1)
|
||||||
status_slug = m.group(2)
|
status_slug = m.group(2)
|
||||||
self._change_status(ref, status_slug, gitlab_user)
|
self._change_status(ref, status_slug, gitlab_user)
|
||||||
|
|
|
@ -134,6 +134,30 @@ def test_push_event_user_story_processing(client):
|
||||||
assert len(mail.outbox) == 1
|
assert len(mail.outbox) == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_push_event_multiple_actions(client):
|
||||||
|
creation_status = f.IssueStatusFactory()
|
||||||
|
role = f.RoleFactory(project=creation_status.project, permissions=["view_issues"])
|
||||||
|
f.MembershipFactory(project=creation_status.project, role=role, user=creation_status.project.owner)
|
||||||
|
new_status = f.IssueStatusFactory(project=creation_status.project)
|
||||||
|
issue1 = f.IssueFactory.create(status=creation_status, project=creation_status.project, owner=creation_status.project.owner)
|
||||||
|
issue2 = f.IssueFactory.create(status=creation_status, project=creation_status.project, owner=creation_status.project.owner)
|
||||||
|
payload = {"commits": [
|
||||||
|
{"message": """test message
|
||||||
|
test TG-%s #%s ok
|
||||||
|
test TG-%s #%s ok
|
||||||
|
bye!
|
||||||
|
""" % (issue1.ref, new_status.slug, issue2.ref, new_status.slug)},
|
||||||
|
]}
|
||||||
|
mail.outbox = []
|
||||||
|
ev_hook1 = event_hooks.PushEventHook(issue1.project, payload)
|
||||||
|
ev_hook1.process_event()
|
||||||
|
issue1 = Issue.objects.get(id=issue1.id)
|
||||||
|
issue2 = Issue.objects.get(id=issue2.id)
|
||||||
|
assert issue1.status.id == new_status.id
|
||||||
|
assert issue2.status.id == new_status.id
|
||||||
|
assert len(mail.outbox) == 2
|
||||||
|
|
||||||
|
|
||||||
def test_push_event_processing_case_insensitive(client):
|
def test_push_event_processing_case_insensitive(client):
|
||||||
creation_status = f.TaskStatusFactory()
|
creation_status = f.TaskStatusFactory()
|
||||||
role = f.RoleFactory(project=creation_status.project, permissions=["view_tasks"])
|
role = f.RoleFactory(project=creation_status.project, permissions=["view_tasks"])
|
||||||
|
|
|
@ -199,6 +199,30 @@ def test_push_event_user_story_processing(client):
|
||||||
assert len(mail.outbox) == 1
|
assert len(mail.outbox) == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_push_event_multiple_actions(client):
|
||||||
|
creation_status = f.IssueStatusFactory()
|
||||||
|
role = f.RoleFactory(project=creation_status.project, permissions=["view_issues"])
|
||||||
|
f.MembershipFactory(project=creation_status.project, role=role, user=creation_status.project.owner)
|
||||||
|
new_status = f.IssueStatusFactory(project=creation_status.project)
|
||||||
|
issue1 = f.IssueFactory.create(status=creation_status, project=creation_status.project, owner=creation_status.project.owner)
|
||||||
|
issue2 = f.IssueFactory.create(status=creation_status, project=creation_status.project, owner=creation_status.project.owner)
|
||||||
|
payload = {"commits": [
|
||||||
|
{"message": """test message
|
||||||
|
test TG-%s #%s ok
|
||||||
|
test TG-%s #%s ok
|
||||||
|
bye!
|
||||||
|
""" % (issue1.ref, new_status.slug, issue2.ref, new_status.slug)},
|
||||||
|
]}
|
||||||
|
mail.outbox = []
|
||||||
|
ev_hook1 = event_hooks.PushEventHook(issue1.project, payload)
|
||||||
|
ev_hook1.process_event()
|
||||||
|
issue1 = Issue.objects.get(id=issue1.id)
|
||||||
|
issue2 = Issue.objects.get(id=issue2.id)
|
||||||
|
assert issue1.status.id == new_status.id
|
||||||
|
assert issue2.status.id == new_status.id
|
||||||
|
assert len(mail.outbox) == 2
|
||||||
|
|
||||||
|
|
||||||
def test_push_event_processing_case_insensitive(client):
|
def test_push_event_processing_case_insensitive(client):
|
||||||
creation_status = f.TaskStatusFactory()
|
creation_status = f.TaskStatusFactory()
|
||||||
role = f.RoleFactory(project=creation_status.project, permissions=["view_tasks"])
|
role = f.RoleFactory(project=creation_status.project, permissions=["view_tasks"])
|
||||||
|
|
Loading…
Reference in New Issue