diff --git a/HISTORY.rst b/HISTORY.rst index 49eaa1d6b8..9b88c4878b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -5,6 +5,7 @@ XX (2017-XX-XX) - Add SANE scanner document source. - Added PDF orientation detection. GitLab issue #387. - Fix repeated permission list API URL. GitLab issue #389. +- Fix role creation API endpoint not returning id. GitLab issue #390. 2.3 (2017-06-08) ================ diff --git a/mayan/apps/permissions/serializers.py b/mayan/apps/permissions/serializers.py index 248452016c..02db390840 100644 --- a/mayan/apps/permissions/serializers.py +++ b/mayan/apps/permissions/serializers.py @@ -75,7 +75,7 @@ class WritableRoleSerializer(serializers.HyperlinkedModelSerializer): if self.permissions_pk_list: self._add_permissions(instance=instance) - return result + return instance def _add_groups(self, instance): instance.groups.add( diff --git a/mayan/apps/permissions/tests/test_api.py b/mayan/apps/permissions/tests/test_api.py index 76f379a230..ddceaa758e 100644 --- a/mayan/apps/permissions/tests/test_api.py +++ b/mayan/apps/permissions/tests/test_api.py @@ -59,9 +59,12 @@ class PermissionAPITestCase(BaseAPITestCase): def test_role_create_view(self): response = self._role_create_request() + role = Role.objects.first() + self.assertEqual(response.status_code, 201) + self.assertEqual(response.data, {'label': role.label, 'id': role.pk}) self.assertEqual(Role.objects.count(), 1) - self.assertEqual(Role.objects.first().label, TEST_ROLE_LABEL) + self.assertEqual(role.label, TEST_ROLE_LABEL) def _create_group(self): self.group = Group.objects.create(name=TEST_GROUP_NAME)