def test_edit_plugin_directly(self): content0 = self.rand_str(prefix='content0_') content1 = self.rand_str(prefix='content1_') content2 = self.rand_str(prefix='content2_') article = self.create_article(content=content0) # Revision 1 self.create_revision(article, content=content1) self.assertEqual( len(default_revision_manager.get_for_object(article)), 1) # Revision 2 with transaction.atomic(): plugins = article.content.get_plugins() plugin = plugins[0].get_plugin_instance()[0] plugin.body = content2 plugin.save() aldryn_create_revision(article) self.assertEqual( len(default_revision_manager.get_for_object(article)), 2) response = self.client.get(article.get_absolute_url()) self.assertContains(response, content2) self.assertNotContains(response, content1) # Revert to revision 1 self.revert_to(article, 1) response = self.client.get(article.get_absolute_url()) self.assertContains(response, content1) self.assertNotContains(response, content2)
def test_edit_plugin_directly(self): job_opening = self.create_default_job_opening() # revision 1 content_en_1 = self.plugin_values_raw['en'].format(1) self.create_revision(job_opening, content=content_en_1) self.assertEqual(len(get_for_object(job_opening)), 1) # revision 2 content_en_2 = self.plugin_values_raw['en'].format(2) with transaction.atomic(): language = job_opening.get_current_language() plugins = job_opening.content.get_plugins().filter( language=language) plugin = plugins[0].get_plugin_instance()[0] plugin.body = content_en_2 plugin.save() aldryn_create_revision(job_opening) self.assertEqual(len(get_for_object(job_opening)), 2) with switch_language(job_opening, 'en'): url = job_opening.get_absolute_url() response = self.client.get(url) self.assertContains(response, content_en_2) self.assertNotContains(response, content_en_1) self.revert_to(job_opening, 1) job_opening = JobOpening.objects.get(pk=job_opening.pk) response = self.client.get(job_opening.get_absolute_url()) self.assertContains(response, content_en_1) self.assertNotContains(response, content_en_2)
def test_edit_plugin_directly(self): content1 = 'Content 1 text' content2 = 'Content 2 text' with force_language('en'): event = self.create_default_event() # revision 1 self.create_event_revision(event, content1) self.assertEqual(len(get_for_object(event)), 1) # revision 2 with transaction.atomic(): plugins = event.description.get_plugins().filter( language=event.get_current_language()) plugin = plugins[0].get_plugin_instance()[0] plugin.body = content2 plugin.save() aldryn_create_revision(event) self.assertEqual(len(get_for_object(event)), 2) response = self.client.get(event.get_absolute_url()) self.assertContains(response, content2) self.assertNotContains(response, content1) self.revert_to(event, 1) event = Event.objects.get(pk=event.pk) response = self.client.get(event.get_absolute_url()) self.assertContains(response, content1) self.assertNotContains(response, content2)