'User can\'t revert a page with plugins to live if he
does not have has change permissions on the Page model,
delete permissions on the plugins in the translation
being reverted and/or does not have page change permissions.'

def test_user_cant_revert_non_empty_page_to_live(self):

    page = self._permissions_page
    staff_user = self.get_staff_user_with_no_permissions()
    translation = self._add_translation_to_page(page)
    endpoint = self.get_admin_url(Page, 'revert_to_live', page.pk, translation.language)
    live_page = page.publisher_public
    draft_plugins = page.placeholders.get(slot='body').get_plugins(translation.language)
    live_plugins = live_page.placeholders.get(slot='body').get_plugins(translation.language)
    self._add_plugin_to_page(page, language=translation.language)
    page.publish(translation.language)
    self._add_plugin_to_page(page, language=translation.language, publish=False)
    self.add_permission(staff_user, 'change_page')
    self.add_page_permission(staff_user, page, can_change=True)
    with self.login_user_context(staff_user):
        self.assertEqual(draft_plugins.count(), 2)
        self.assertEqual(live_plugins.count(), 1)
        data = {'language': translation.language}
        response = self.client.post(endpoint, data)
        self.assertEqual(response.status_code, 403)
        self.assertEqual(draft_plugins.count(), 2)
        self.assertEqual(live_plugins.count(), 1)
