Skip to content

Commit 27cad04

Browse files
authored
Fix 500 error on POST to /questionnaire/relationships (#461)
Sending a POST request to `/questionnaire/relationships` was failing because it was falling into the non-relationship block handling code. Although we wouldn't expect this behaviour, it has been observed during testing, and should be handled properly. To fix this `POST` has been enabled on the `/questionnaire/relationships` endpoint, which consequently does the same as the `GET` and redirects to the first relationship.
1 parent 9893e7a commit 27cad04

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

app/routes/questionnaire.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def block(schema, questionnaire_store, block_id, list_name=None, list_item_id=No
220220

221221
@questionnaire_blueprint.route(
222222
"relationships/",
223-
methods=["GET"],
223+
methods=["GET", "POST"],
224224
)
225225
@questionnaire_blueprint.route(
226226
"relationships/<list_name>/<list_item_id>/to/<to_list_item_id>/",

tests/integration/questionnaire/test_questionnaire_relationships.py

+8
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,11 @@ def test_relationship_not_altered_when_new_list_item_not_submitted(self):
118118
self.post({"anyone-else": "No"})
119119

120120
self.assertEqual(list_item_ids_original, list_item_ids_new)
121+
122+
def test_post_to_relationships_root(self):
123+
self.launchSurvey("test_relationships")
124+
self.add_person("Marie", "Doe")
125+
self.add_person("John", "Doe")
126+
self.post({"anyone-else": "No"})
127+
self.post(url="/questionnaire/relationships")
128+
self.assertStatusOK()

0 commit comments

Comments
 (0)