kopia lustrzana https://github.com/wagtail/wagtail
Use double-quotes in modal_workflow responses for JSON-consistency
rodzic
8b3d3a7af8
commit
87c247faa1
|
@ -13,11 +13,11 @@ def render_modal_workflow(request, html_template, js_template, template_vars=Non
|
|||
|
||||
if html_template:
|
||||
html = render_to_string(html_template, template_vars or {}, request=request)
|
||||
response_keyvars.append("'html': %s" % json.dumps(html))
|
||||
response_keyvars.append('"html": %s' % json.dumps(html))
|
||||
|
||||
if js_template:
|
||||
js = render_to_string(js_template, template_vars or {}, request=request)
|
||||
response_keyvars.append("'onload': %s" % js)
|
||||
response_keyvars.append('"onload": %s' % js)
|
||||
|
||||
if json_data:
|
||||
for key, val in json_data.items():
|
||||
|
|
|
@ -467,7 +467,7 @@ class TestChooserExternalLink(TestCase, WagtailTestUtils):
|
|||
def test_create_link(self):
|
||||
response = self.post({'url': 'http://www.example.com/', 'link_text': 'example'})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "'onload'") # indicates success / post back to calling page
|
||||
self.assertContains(response, '"onload"') # indicates success / post back to calling page
|
||||
self.assertContains(response, '"url": "http://www.example.com/"')
|
||||
self.assertContains(response, '"title": "example"') # When link text is given, it is used
|
||||
self.assertContains(response, '"prefer_this_title_as_link_text": true')
|
||||
|
@ -475,7 +475,7 @@ class TestChooserExternalLink(TestCase, WagtailTestUtils):
|
|||
def test_create_link_without_text(self):
|
||||
response = self.post({'url': 'http://www.example.com/'})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "'onload'") # indicates success / post back to calling page
|
||||
self.assertContains(response, '"onload"') # indicates success / post back to calling page
|
||||
self.assertContains(response, '"url": "http://www.example.com/"')
|
||||
self.assertContains(response, '"title": "http://www.example.com/"') # When no text is given, it uses the url
|
||||
self.assertContains(response, '"prefer_this_title_as_link_text": false')
|
||||
|
@ -502,13 +502,13 @@ class TestChooserExternalLink(TestCase, WagtailTestUtils):
|
|||
def test_invalid_url(self):
|
||||
response = self.post({'url': 'ntp://www.example.com', 'link_text': 'example'})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "'html'") # indicates failure / show error message
|
||||
self.assertContains(response, '"html"') # indicates failure / show error message
|
||||
self.assertContains(response, "Enter a valid URL.")
|
||||
|
||||
def test_allow_local_url(self):
|
||||
response = self.post({'url': '/admin/', 'link_text': 'admin'})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "'onload'") # indicates success / post back to calling page
|
||||
self.assertContains(response, '"onload"') # indicates success / post back to calling page
|
||||
self.assertContains(response, '"url": "/admin/"')
|
||||
self.assertContains(response, '"title": "admin"')
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue