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():
|
||||
modelClass = Issue
|
||||
statusClass = IssueStatus
|
||||
elif Task.objects.filter(ref=ref).exists():
|
||||
elif Task.objects.filter(project=self.project, ref=ref).exists():
|
||||
modelClass = Task
|
||||
statusClass = TaskStatus
|
||||
elif UserStory.objects.filter(ref=ref).exists():
|
||||
elif UserStory.objects.filter(project=self.project, ref=ref).exists():
|
||||
modelClass = UserStory
|
||||
statusClass = UserStoryStatus
|
||||
else:
|
||||
|
@ -87,7 +87,7 @@ class PushEventHook(BaseEventHook):
|
|||
|
||||
try:
|
||||
status = statusClass.objects.get(project=self.project, slug=status_slug)
|
||||
except IssueStatus.DoesNotExist:
|
||||
except statusClass.DoesNotExist:
|
||||
raise ActionSyntaxException(_("The status doesn't exist"))
|
||||
|
||||
element.status = status
|
||||
|
|
|
@ -146,7 +146,7 @@ def test_push_event_processing_case_insensitive(client):
|
|||
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()
|
||||
payload = {"commits": [
|
||||
{"message": """test message
|
||||
|
@ -164,6 +164,25 @@ def test_push_event_bad_processing_non_existing_ref(client):
|
|||
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):
|
||||
issue = f.IssueFactory.create()
|
||||
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 len(mail.outbox) == 0
|
||||
|
||||
|
||||
def test_issues_event_opened_issue(client):
|
||||
issue = f.IssueFactory.create()
|
||||
issue.project.default_issue_status = issue.status
|
||||
|
|
Loading…
Reference in New Issue