Add test for #123
This commit is contained in:
parent
96440f1933
commit
d6adc3eab5
3 changed files with 18 additions and 5 deletions
|
@ -71,9 +71,6 @@ HELPER_SETTINGS = {
|
|||
'hide_untranslated': False,
|
||||
}
|
||||
},
|
||||
'MIDDLEWARE_CLASSES': [
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
],
|
||||
'MIGRATION_MODULES': {
|
||||
'cmsplugin_filer_image': 'cmsplugin_filer_image.migrations_django',
|
||||
},
|
||||
|
|
|
@ -145,8 +145,10 @@ class BaseTest(TestCase):
|
|||
request.errors = StringIO()
|
||||
return request
|
||||
|
||||
def post_request(self, page, lang, data):
|
||||
request = self.request_factory.post(page.get_path(lang), data)
|
||||
def post_request(self, page, lang, data, path=None):
|
||||
if not path:
|
||||
path = page.get_path(lang)
|
||||
request = self.request_factory.post(path, data)
|
||||
request.current_page = page
|
||||
request.user = self.user
|
||||
request.session = {}
|
||||
|
|
|
@ -90,6 +90,20 @@ class AdminTest(BaseTest):
|
|||
self.assertEqual(Post.objects.count(), 3)
|
||||
self.assertEqual(Post.objects.get(translations__slug='third-post').author.username, 'staff')
|
||||
|
||||
def test_admin_post_text(self):
|
||||
page1, page2 = self.get_pages()
|
||||
post = self._get_post(self.data['en'][0])
|
||||
|
||||
with self.settings(BLOG_USE_PLACEHOLDER=False):
|
||||
data = {'post_text': 'ehi text'}
|
||||
request = self.post_request(page1, 'en', data=data, path='/en/?edit_fields=post_text')
|
||||
msg_mid = MessageMiddleware()
|
||||
msg_mid.process_request(request)
|
||||
post_admin = admin.site._registry[Post]
|
||||
post_admin.edit_field(request, post.pk, 'en')
|
||||
modified_post = Post.objects.get(pk=post.pk)
|
||||
self.assertEqual(modified_post.safe_translation_getter('post_text'), data['post_text'])
|
||||
|
||||
|
||||
class ModelsTest(BaseTest):
|
||||
|
||||
|
|
Loading…
Reference in a new issue