Fixing bug when changing us's to a non existing status
parent
2d90a5dac9
commit
2e78d51eda
|
@ -74,10 +74,10 @@ class PushEventHook(BaseEventHook):
|
||||||
if Issue.objects.filter(project=self.project, ref=ref).exists():
|
if Issue.objects.filter(project=self.project, ref=ref).exists():
|
||||||
modelClass = Issue
|
modelClass = Issue
|
||||||
statusClass = IssueStatus
|
statusClass = IssueStatus
|
||||||
elif Task.objects.filter(ref=ref).exists():
|
elif Task.objects.filter(project=self.project, ref=ref).exists():
|
||||||
modelClass = Task
|
modelClass = Task
|
||||||
statusClass = TaskStatus
|
statusClass = TaskStatus
|
||||||
elif UserStory.objects.filter(ref=ref).exists():
|
elif UserStory.objects.filter(project=self.project, ref=ref).exists():
|
||||||
modelClass = UserStory
|
modelClass = UserStory
|
||||||
statusClass = UserStoryStatus
|
statusClass = UserStoryStatus
|
||||||
else:
|
else:
|
||||||
|
@ -87,7 +87,7 @@ class PushEventHook(BaseEventHook):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
status = statusClass.objects.get(project=self.project, slug=status_slug)
|
status = statusClass.objects.get(project=self.project, slug=status_slug)
|
||||||
except IssueStatus.DoesNotExist:
|
except statusClass.DoesNotExist:
|
||||||
raise ActionSyntaxException(_("The status doesn't exist"))
|
raise ActionSyntaxException(_("The status doesn't exist"))
|
||||||
|
|
||||||
element.status = status
|
element.status = status
|
||||||
|
|
|
@ -146,7 +146,7 @@ def test_push_event_processing_case_insensitive(client):
|
||||||
assert len(mail.outbox) == 1
|
assert len(mail.outbox) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_push_event_bad_processing_non_existing_ref(client):
|
def test_push_event_task_bad_processing_non_existing_ref(client):
|
||||||
issue_status = f.IssueStatusFactory()
|
issue_status = f.IssueStatusFactory()
|
||||||
payload = {"commits": [
|
payload = {"commits": [
|
||||||
{"message": """test message
|
{"message": """test message
|
||||||
|
@ -164,6 +164,25 @@ def test_push_event_bad_processing_non_existing_ref(client):
|
||||||
assert len(mail.outbox) == 0
|
assert len(mail.outbox) == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_push_event_us_bad_processing_non_existing_status(client):
|
||||||
|
user_story = f.UserStoryFactory.create()
|
||||||
|
payload = {"commits": [
|
||||||
|
{"message": """test message
|
||||||
|
test TG-%s #non-existing-slug ok
|
||||||
|
bye!
|
||||||
|
"""%(user_story.ref)},
|
||||||
|
]}
|
||||||
|
|
||||||
|
mail.outbox = []
|
||||||
|
|
||||||
|
ev_hook = event_hooks.PushEventHook(user_story.project, payload)
|
||||||
|
with pytest.raises(ActionSyntaxException) as excinfo:
|
||||||
|
ev_hook.process_event()
|
||||||
|
|
||||||
|
assert str(excinfo.value) == "The status doesn't exist"
|
||||||
|
assert len(mail.outbox) == 0
|
||||||
|
|
||||||
|
|
||||||
def test_push_event_bad_processing_non_existing_status(client):
|
def test_push_event_bad_processing_non_existing_status(client):
|
||||||
issue = f.IssueFactory.create()
|
issue = f.IssueFactory.create()
|
||||||
payload = {"commits": [
|
payload = {"commits": [
|
||||||
|
@ -182,6 +201,7 @@ def test_push_event_bad_processing_non_existing_status(client):
|
||||||
assert str(excinfo.value) == "The status doesn't exist"
|
assert str(excinfo.value) == "The status doesn't exist"
|
||||||
assert len(mail.outbox) == 0
|
assert len(mail.outbox) == 0
|
||||||
|
|
||||||
|
|
||||||
def test_issues_event_opened_issue(client):
|
def test_issues_event_opened_issue(client):
|
||||||
issue = f.IssueFactory.create()
|
issue = f.IssueFactory.create()
|
||||||
issue.project.default_issue_status = issue.status
|
issue.project.default_issue_status = issue.status
|
||||||
|
|
Loading…
Reference in New Issue