From 55f08021345c54f70d699868a7622ac3f95840dc Mon Sep 17 00:00:00 2001 From: Christian Zosel Date: Wed, 5 Jun 2019 10:15:53 +0200 Subject: [PATCH] Patch request with "meta" attribute fails --- example/migrations/0001_initial.py | 1 + example/models.py | 1 + example/tests/test_views.py | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/example/migrations/0001_initial.py b/example/migrations/0001_initial.py index 38cc0be9..89b3f873 100644 --- a/example/migrations/0001_initial.py +++ b/example/migrations/0001_initial.py @@ -61,6 +61,7 @@ class Migration(migrations.Migration): ('modified_at', models.DateTimeField(auto_now=True)), ('body', models.TextField()), ('author', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='example.Author')), + ('meta', models.CharField(max_length=50)), ], options={ 'abstract': False, diff --git a/example/models.py b/example/models.py index 179cbfe5..f30deeb8 100644 --- a/example/models.py +++ b/example/models.py @@ -127,6 +127,7 @@ class Comment(BaseModel): on_delete=models.CASCADE, related_name='comments', ) + meta = models.CharField(max_length=50) def __str__(self): return self.body diff --git a/example/tests/test_views.py b/example/tests/test_views.py index 1e54c987..45054e31 100644 --- a/example/tests/test_views.py +++ b/example/tests/test_views.py @@ -205,6 +205,21 @@ def test_delete_relationship_overriding_with_none(self): assert response.status_code == 200, response.content.decode() assert response.data['author'] is None + def test_patch_meta(self): + url = '/comments/{}'.format(self.second_comment.id) + request_data = { + 'data': { + 'type': 'comments', + 'id': self.second_comment.id, + 'attributes': { + 'meta': "test" + } + } + } + response = self.client.patch(url, data=request_data) + assert response.status_code == 200, response.content.decode() + assert response.data['meta'] == "test" + def test_delete_to_many_relationship_with_no_change(self): url = '/entries/{}/relationships/comments'.format(self.first_entry.id) request_data = {