From f656823ceb9cd42cef4408cbda6069449fff9a0b Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 26 Mar 2025 14:33:03 -0700 Subject: [PATCH] Update test_adapter.py --- src/paperless/tests/test_adapter.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/paperless/tests/test_adapter.py b/src/paperless/tests/test_adapter.py index abd2fc28b..b87c47096 100644 --- a/src/paperless/tests/test_adapter.py +++ b/src/paperless/tests/test_adapter.py @@ -106,6 +106,27 @@ class TestCustomAccountAdapter(TestCase): self.assertTrue(user.groups.filter(name="group1").exists()) self.assertFalse(user.groups.filter(name="group2").exists()) + def test_fresh_install_save_creates_superuser(self): + adapter = get_adapter() + form = mock.Mock( + cleaned_data={ + "username": "testuser", + "email": "user@paperless-ngx.com", + }, + ) + user = adapter.save_user(HttpRequest(), User(), form, commit=True) + self.assertTrue(user.is_superuser) + + # Next time, it should not create a superuser + form = mock.Mock( + cleaned_data={ + "username": "testuser2", + "email": "user2@paperless-ngx.com", + }, + ) + user2 = adapter.save_user(HttpRequest(), User(), form, commit=True) + self.assertFalse(user2.is_superuser) + class TestCustomSocialAccountAdapter(TestCase): def test_is_open_for_signup(self):