'User can clear a placeholder with plugins if he has
change permissions on the Page model, delete permissions
on the plugin models in the placeholder and global change permissions.'

def test_user_can_clear_non_empty_placeholder(self):

    page = self._permissions_page
    staff_user = self.get_staff_user_with_no_permissions()
    plugins = [self._add_plugin_to_page(page, 'TextPlugin'), self._add_plugin_to_page(page, 'LinkPlugin')]
    placeholder = plugins[0].placeholder
    endpoint = self.get_clear_placeholder_url(placeholder)
    self.add_permission(staff_user, 'delete_text')
    self.add_permission(staff_user, 'delete_link')
    self.add_permission(staff_user, 'change_page')
    self.add_global_permission(staff_user, can_change=True)
    with self.login_user_context(staff_user):
        response = self.client.post(endpoint, {'test': 0})
        self.assertEqual(response.status_code, 302)
        self.assertEqual(placeholder.get_plugins('en').count(), 0)
