diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html index 064e5fc2b4..db9d278d36 100644 --- a/trac/ticket/templates/ticket.html +++ b/trac/ticket/templates/ticket.html @@ -79,6 +79,7 @@ var comment_focused = false; $("#comment").focus(function() { comment_focused = true; }) .blur(function() { comment_focused = false; }); + # if not disable_submit: $("#propertyform").autoSubmit({preview: '1'}, function(data, reply) { var items = $(reply); // Update ticket box @@ -113,8 +114,9 @@ .next("div.comment").html(reply); comment.toggle(comment.children().length != 0); }, "#changelog .trac-loading"); + # endif - # else: + # elif not disable_submit: $("#propertyform").autoSubmit({preview: '1'}, function(data, reply) { $('#ticket').replaceWith(reply); }, "#ticket .trac-loading"); diff --git a/trac/ticket/tests/web_ui.py b/trac/ticket/tests/web_ui.py index 5f4585a39f..90abbc3e22 100644 --- a/trac/ticket/tests/web_ui.py +++ b/trac/ticket/tests/web_ui.py @@ -119,6 +119,9 @@ def _has_auto_preview(self, req): in s['attrs']['src'] for s in req.chrome['scripts']) + def _render_fragment(self, req, template, data): + return Chrome(self.env).render_fragment(req, template, data) + def _insert_ticket(self, **kw): """Helper for inserting a ticket into the database""" return insert_ticket(self.env, **kw) @@ -702,7 +705,7 @@ def _test_render_time_field(self, format, req, value, expected): def timefield_text(): self.assertTrue(self.ticket_module.match_request(req)) template, data = self.ticket_module.process_request(req) - content = Chrome(self.env).render_fragment(req, template, data) + content = self._render_fragment(req, template, data) # select('//td[@headers="h_timefield"') replacement class TimefieldExtractor(HTMLTransform): pick_next_text = False @@ -870,9 +873,11 @@ def test_newticket_has_auto_preview(self): req = MockRequest(self.env, method='GET', path_info='/newticket') self.assertTrue(self.ticket_module.match_request(req)) - self.ticket_module.process_request(req) + template, data = self.ticket_module.process_request(req) self.assertTrue(self._has_auto_preview(req)) + content = self._render_fragment(req, template, data) + self.assertIn('.autoSubmit(', content) def test_newticket_autopreview_disabled_when_no_workflow_actions(self): """Newticket autopreview disabled when no workflow actions.""" @@ -882,11 +887,13 @@ def test_newticket_autopreview_disabled_when_no_workflow_actions(self): req = MockRequest(self.env, method='GET', path_info='/newticket') self.assertTrue(self.ticket_module.match_request(req)) - data = self.ticket_module.process_request(req)[1] + template, data = self.ticket_module.process_request(req) self.assertEqual([], data['action_controls']) self.assertFalse(self._has_auto_preview(req)) self.assertTrue(data['disable_submit']) + content = self._render_fragment(req, template, data) + self.assertNotIn('.autoSubmit(', content) def test_ticket_autopreview_disabled_when_no_workflow_actions(self): """Ticket autopreview disabled when no workflow actions.""" @@ -898,11 +905,13 @@ def test_ticket_autopreview_disabled_when_no_workflow_actions(self): req = MockRequest(self.env, method='GET', path_info='/ticket/1') self.assertTrue(self.ticket_module.match_request(req)) - data = self.ticket_module.process_request(req)[1] + template, data = self.ticket_module.process_request(req) self.assertEqual([], data['action_controls']) self.assertFalse(self._has_auto_preview(req)) self.assertTrue(data['disable_submit']) + content = self._render_fragment(req, template, data) + self.assertNotIn('.autoSubmit(', content) def test_new_ticket_without_ticket_edit_cc(self): """User without TICKET_EDIT_CC can only add themselves to CC.