Skip to content
This repository was archived by the owner on Apr 10, 2023. It is now read-only.

tinymce-jsonconfiguration declares correct content type #126

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Products/TinyMCE/browser/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ def jsonConfiguration(self, field):
"""Return the configuration in JSON"""

utility = getToolByName(aq_inner(self.context), 'portal_tinymce')
self.request.RESPONSE.setHeader(
'content-type',
'application/json;charset=utf-8'
)
return json.dumps(utility.getConfiguration(context=self.context,
field=field,
request=self.request))
Expand Down
10 changes: 8 additions & 2 deletions Products/TinyMCE/tests/test_widget_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ def test_at_button_settings(self):
to the generated config JSON.
"""
dummy = self.mockAtContent()
view = getMultiAdapter((dummy, self.portal.REQUEST), name="tinymce-jsonconfiguration")
view = getMultiAdapter(
(dummy, self.portal.REQUEST.clone()),
name="tinymce-jsonconfiguration"
)
view = view.__of__(dummy)

# Settings output as JSON
output = view(field=dummy.getField('testfield'))

self.assertEqual(
view.request.response.getHeader('content-type'),
'application/json;charset=utf-8',
)
data = json.loads(output)

# No other buttons should be available
Expand Down