Skip to content

Commit

Permalink
Fix double workflow DB fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Sep 4, 2022
1 parent ce514b2 commit 7b1ab9d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 1 addition & 3 deletions joeflow/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def get_task(self):

def next_task(self):
task = self.get_task()
task.workflow = self.model._base_manager.get(
pk=self.model._base_manager.get(pk=self.object.pk)
)
task.workflow = self.model._base_manager.get(pk=self.object.pk)
task.finish(self.request.user)
task.start_next_tasks()

Expand Down
17 changes: 17 additions & 0 deletions tests/tasks/test_human.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pytest

from tests.testapp import workflows


class TestStartView:
def test_get(self, client):
response = client.get("/simple/start_view/custom/postfix/")
assert response.status_code == 200

@pytest.mark.django_db
def test_post(self, client):
assert not workflows.SimpleWorkflow.objects.exists()
response = client.post("/simple/start_view/custom/postfix/")
assert response.status_code == 302
assert response["Location"] == "/simple/1/"
assert workflows.SimpleWorkflow.objects.exists()

0 comments on commit 7b1ab9d

Please sign in to comment.