]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
REST: Check.user is not read-only
authorStephen Finucane <stephen@that.guru>
Sun, 24 Jun 2018 19:55:47 +0000 (20:55 +0100)
committerDaniel Axtens <dja@axtens.net>
Sun, 26 Aug 2018 02:14:40 +0000 (12:14 +1000)
We only support 'Check' creation - not check updating. As a result,
there's no real reason that the 'Check.user' field should be read-only
and this is causing an issue with Django REST Framework 3.7. Simply
remove the attribute and extend the tests to validate things are working
as expected.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
patchwork/api/check.py
patchwork/tests/api/test_check.py

index 8753c7de4e6c9c46485784649a35b4de2b378d15..5e461de6b349b8a01d1e4bf90c36788b909c6a4d 100644 (file)
@@ -44,7 +44,7 @@ class CheckSerializer(HyperlinkedModelSerializer):
 
     url = CheckHyperlinkedIdentityField('api-check-detail')
     patch = HiddenField(default=CurrentPatchDefault())
-    user = UserSerializer(read_only=True, default=CurrentUserDefault())
+    user = UserSerializer(default=CurrentUserDefault())
 
     def run_validation(self, data):
         for val, label in Check.STATE_CHOICES:
index 43181af3d85d71a873af6e4296dcd20ce3c67abc..0e7e0cfc3dd3c43e24631810c0fe2f9a6281191f 100644 (file)
@@ -67,6 +67,7 @@ class TestCheckAPI(APITestCase):
         self.assertEqual(check_obj.target_url, check_json['target_url'])
         self.assertEqual(check_obj.context, check_json['context'])
         self.assertEqual(check_obj.description, check_json['description'])
+        self.assertEqual(check_obj.user.id, check_json['user']['id'])
 
     def test_list(self):
         """Validate we can list checks on a patch."""