summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_state.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py
index 2ad8025122..7a959c53eb 100644
--- a/tests/migrations/test_state.py
+++ b/tests/migrations/test_state.py
@@ -166,6 +166,26 @@ class StateTests(SimpleTestCase):
self.assertEqual([mgr.args for name, mgr in food_order_manager_state.managers],
[('a', 'b', 1, 2), ('x', 'y', 3, 4)])
+ def test_custom_default_manager_added_to_the_model_state(self):
+ """
+ When the default manager of the model is a custom manager,
+ it needs to be added to the model state.
+ """
+ new_apps = Apps(['migrations'])
+ custom_manager = models.Manager()
+
+ class Author(models.Model):
+ objects = models.TextField()
+ authors = custom_manager
+
+ class Meta:
+ app_label = 'migrations'
+ apps = new_apps
+
+ project_state = ProjectState.from_apps(new_apps)
+ author_state = project_state.models['migrations', 'author']
+ self.assertEqual(author_state.managers, [('authors', custom_manager)])
+
def test_apps_bulk_update(self):
"""
StateApps.bulk_update() should update apps.ready to False and reset