diff options
author | Matthias Kestenholz <mk@feinheit.ch> | 2018-11-10 00:52:30 +0100 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-11-09 18:52:30 -0500 |
commit | f9ff1df1daac8ae1fc22b27f48735148cb5488dd (patch) | |
tree | 87ff7dbda0dfcb0a896c892ef441cffa4f8c401f /tests/modeladmin | |
parent | a375e911efcc78054d09ef31422e081507e56623 (diff) | |
download | django-f9ff1df1daac8ae1fc22b27f48735148cb5488dd.tar.gz |
Fixed #29917 -- Stopped collecting ModelAdmin.actions from base ModelAdmins.
Diffstat (limited to 'tests/modeladmin')
-rw-r--r-- | tests/modeladmin/test_actions.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/modeladmin/test_actions.py b/tests/modeladmin/test_actions.py index 17b3c324d2..a33c1811b2 100644 --- a/tests/modeladmin/test_actions.py +++ b/tests/modeladmin/test_actions.py @@ -55,3 +55,24 @@ class AdminActionsTests(TestCase): mock_request.user = user actions = ma.get_actions(mock_request) self.assertEqual(list(actions.keys()), expected) + + def test_actions_inheritance(self): + class AdminBase(admin.ModelAdmin): + actions = ['custom_action'] + + def custom_action(modeladmin, request, queryset): + pass + + class AdminA(AdminBase): + pass + + class AdminB(AdminBase): + actions = None + + ma1 = AdminA(Band, admin.AdminSite()) + action_names = [name for _, name, _ in ma1._get_base_actions()] + self.assertEqual(action_names, ['delete_selected', 'custom_action']) + # `actions = None` removes actions from superclasses. + ma2 = AdminB(Band, admin.AdminSite()) + action_names = [name for _, name, _ in ma2._get_base_actions()] + self.assertEqual(action_names, ['delete_selected']) |