fix(core): ensure slash command is called on ticket description

ref: #744 #723
This commit is contained in:
2025-05-10 16:42:05 +09:30
parent f71e304731
commit e366220e8b
2 changed files with 57 additions and 0 deletions

View File

@ -819,5 +819,18 @@ class TicketBase(
self.date_closed = datetime.datetime.now(tz=datetime.timezone.utc).replace(microsecond=0).isoformat()
if(
self.description != ''
and self.description is not None
):
description = self.slash_command(self.description)
if description != self.description:
self.description = description
super().save(force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)

View File

@ -893,6 +893,26 @@ class TicketBaseModelTestCases(
assert spy.assert_called_once
def test_function_save_called_slash_command(self, model, mocker, ticket):
"""Function Check
Ensure function `TicketCommentBase.clean` is called
"""
spy = mocker.spy(self.model, 'slash_command')
valid_data = self.kwargs_create_item.copy()
valid_data['title'] = 'was save called'
del valid_data['external_system']
item = model.objects.create(
**valid_data
)
spy.assert_called_with(item, valid_data['description'])
class TicketBaseModelInheritedCases(
@ -945,3 +965,27 @@ class TicketBaseModelPyTest(
"""
assert type(self.model().get_related_model()) is type(None)
def test_function_save_called_slash_command(self, model, mocker, ticket):
"""Function Check
This test case is a duplicate of a test with the same name. This
test is required so that the base class `save()` function can be tested.
Ensure function `TicketCommentBase.clean` is called
"""
spy = mocker.spy(self.model, 'slash_command')
valid_data = self.kwargs_create_item.copy()
valid_data['title'] = 'was save called'
del valid_data['external_system']
item = model.objects.create(
**valid_data
)
spy.assert_called_with(item, valid_data['description'])