summaryrefslogtreecommitdiff
path: root/tests/custom_managers
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-12-30 18:00:36 -0500
committerGitHub <noreply@github.com>2017-12-30 18:00:36 -0500
commitd065c92678f5d11a70b88e195c6357576eb3a2ef (patch)
tree49584bddeda291f8c5a79086e9994536d80bcf91 /tests/custom_managers
parentdcdd219ee1e062dc6189f382e0298e0adf5d5ddf (diff)
Fixed #28918 -- Fixed Model.refresh_from_db() for instances hidden by the default manager.
Diffstat (limited to 'tests/custom_managers')
-rw-r--r--tests/custom_managers/tests.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/custom_managers/tests.py b/tests/custom_managers/tests.py
index ee2ac1d552..a545382d8f 100644
--- a/tests/custom_managers/tests.py
+++ b/tests/custom_managers/tests.py
@@ -607,6 +607,16 @@ class CustomManagersRegressTestCase(TestCase):
# there would now be two objects in the database.
self.assertEqual(RestrictedModel.plain_manager.count(), 1)
+ def test_refresh_from_db_when_default_manager_filters(self):
+ """
+ Model.refresh_from_db() works for instances hidden by the default
+ manager.
+ """
+ book = Book._base_manager.create(is_published=False)
+ Book._base_manager.filter(pk=book.pk).update(title='Hi')
+ book.refresh_from_db()
+ self.assertEqual(book.title, 'Hi')
+
def test_delete_related_on_filtered_manager(self):
"""Deleting related objects should also not be distracted by a
restricted manager on the related object. This is a regression