'User can delete a plugin if he has change permissions
on the Page model, delete permissions on the plugin model
and global change permissions.'

def test_user_can_delete_plugin(self):

    page = self.get_permissions_test_page()
    staff_user = self.get_staff_user_with_no_permissions()
    plugin = self._add_plugin_to_page(page)
    endpoint = self.get_delete_plugin_uri(plugin)
    self.add_permission(staff_user, 'change_page')
    self.add_permission(staff_user, 'delete_link')
    self.add_global_permission(staff_user, can_change=True)
    with self.login_user_context(staff_user):
        data = {'post': True}
        response = self.client.post(endpoint, data)
        self.assertEqual(response.status_code, 302)
        self.assertFalse(CMSPlugin.objects.filter(pk=plugin.pk).exists())
