Fix API item default kind

This commit is contained in:
rucki
2026-09-12 11:50:29 +02:00
parent be76e91e89
commit 645cf94056
3 changed files with 28 additions and 2 deletions
+26
View File
@@ -245,6 +245,8 @@ class DefaultItemKindTests(TestCase):
def test_new_item_editor_uses_user_default(self):
response = self.client.get(reverse('new_item'))
self.assertEqual(response.context['requested_kind'], Item.Kind.TODO)
self.assertContains(response, 'Typ:')
self.assertContains(response, 'Aufgabe')
class DueDateCommandTests(TestCase):
@@ -1122,6 +1124,30 @@ class ApiItemFilterTests(TestCase):
self.assertEqual(len(items), 1)
self.assertEqual(items[0]['id'], second.id)
def test_api_create_ignores_user_default_kind(self):
UserPreference.objects.create(user=self.user, default_item_kind=Item.Kind.TODO)
response = self.client.post(
reverse('api_items'), {'content': 'API note #help'},
HTTP_X_API_KEY=self.api_key.token,
)
self.assertEqual(response.status_code, 201)
item = Item.objects.get(content='API note #help')
self.assertEqual(item.kind, Item.Kind.NOTE)
def test_api_create_still_accepts_explicit_kind(self):
UserPreference.objects.create(user=self.user, default_item_kind=Item.Kind.NOTE)
response = self.client.post(
reverse('api_items'), {'content': 'API task #help', 'kind': Item.Kind.TODO},
HTTP_X_API_KEY=self.api_key.token,
)
self.assertEqual(response.status_code, 201)
item = Item.objects.get(content='API task #help')
self.assertEqual(item.kind, Item.Kind.TODO)
class CopyButtonTests(TestCase):
def test_item_has_copy_button_with_original_text(self):