Commit d7f6bf12 authored by Jérome Perrin's avatar Jérome Perrin

hal_json_style: fix double translation of worklist message

There was a regression with 45c03413 (hal_json_style: prevent a
translation of worklist with document count, 2021-05-10), the title
of the worklist was translated twice. This was supposed to be
catched by the test, by checking that the mocked gettext had only
one call for "Draft to Validate", assuming that the translation of
"Draft to Validate" was "Draft to Validate" and that a double
translation would cause this to be translated twice, but because of
a side effect of another test inserting a translation for
"Draft to Validate", this problem was not noticed.

This fixes the double translation and adjust the test to not depend
on the actual content of message catalog.
parent bb90ac9d
......@@ -1546,10 +1546,11 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
'href': '%s' % view_action['url'],
'name': view_action['id'],
'icon': view_action['icon'],
'title': Base_translateString(
translateWorklistActionName(view_action['title'])
if 'worklist_id' in view_action
else view_action['title']),
'title': translateWorklistActionName(
view_action['title']
) if 'worklist_id' in view_action else Base_translateString(
view_action['title']
),
})
global_action_type = ("view", "workflow", "object_new_content_action",
......
......@@ -2942,9 +2942,8 @@ return msg"
# worklists with the actual count of document
fake_request = do_fake_request("GET")
default_gettext = self.portal.Localizer.erp5_ui.gettext
def gettext(message, **kw):
return default_gettext(message, **kw)
return kw.get('default', message)
with mock.patch.object(self.portal.Localizer.erp5_ui.__class__, 'gettext', side_effect=gettext) as gettext_mock:
self.portal.web_site_module.hateoas.ERP5Document_getHateoas(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment