diff --git a/taiga/webhooks/signal_handlers.py b/taiga/webhooks/signal_handlers.py index af964b0a..e15cd1de 100644 --- a/taiga/webhooks/signal_handlers.py +++ b/taiga/webhooks/signal_handlers.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from django.db import connection from django.conf import settings from django.utils import timezone @@ -61,6 +62,6 @@ def on_new_history_entry(sender, instance, created, **kwargs): args = [webhook["id"], webhook["url"], webhook["key"], obj] + extra_args if settings.CELERY_ENABLED: - task.delay(*args) + connection.on_commit(lambda: task.delay(*args)) else: - task(*args) + connection.on_commit(lambda: task(*args)) diff --git a/tests/integration/test_webhooks.py b/tests/integration/test_webhooks.py index cf698bc8..555a321b 100644 --- a/tests/integration/test_webhooks.py +++ b/tests/integration/test_webhooks.py @@ -22,7 +22,7 @@ from .. import factories as f from taiga.projects.history import services -pytestmark = pytest.mark.django_db +pytestmark = pytest.mark.django_db(transaction=True) def test_new_object_with_one_webhook(settings):