From 3a44804c964f6d5f09e90b0ec6fd54bea37512dd Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 2 Jan 2015 11:31:52 +0100 Subject: [PATCH] Added html quoting, text2html and linkify. --- .../_application_controller.js.coffee | 24 +++--- .../controllers/widget/maintenance.js.coffee | 6 +- test/browser/maintenance_message_test.rb | 80 ++++++++++++------- 3 files changed, 66 insertions(+), 44 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller.js.coffee b/app/assets/javascripts/app/controllers/_application_controller.js.coffee index e28c581a5..803a08980 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.js.coffee @@ -489,15 +489,15 @@ class App.ControllerModal extends App.Controller @button = 'Submit' @html App.view('modal') - head: @head - message: @message - detail: @detail - close: @close - cancel: @cancel - button: @button - buttonClass: @buttonClass - centerButtons:@centerButtons - content: content + head: @head + message: @message + detail: @detail + close: @close + cancel: @cancel + button: @button + buttonClass: @buttonClass + centerButtons: @centerButtons + content: content if @content @body.html @content @@ -507,8 +507,8 @@ class App.ControllerModal extends App.Controller show: true backdrop: @backdrop .on - 'show.bs.modal': @onShow - 'shown.bs.modal': @onShown + 'show.bs.modal': @onShow + 'shown.bs.modal': @onShown 'hidden.bs.modal': => @onHide() # remove modal from dom @@ -543,7 +543,7 @@ class App.ErrorModal extends App.ControllerModal class App.SessionMessage extends App.ControllerModal constructor: -> super - @show() + @show(@content) # reload page on modal hidden onHide: (e) => diff --git a/app/assets/javascripts/app/controllers/widget/maintenance.js.coffee b/app/assets/javascripts/app/controllers/widget/maintenance.js.coffee index 384b5f623..5674c7283 100644 --- a/app/assets/javascripts/app/controllers/widget/maintenance.js.coffee +++ b/app/assets/javascripts/app/controllers/widget/maintenance.js.coffee @@ -16,9 +16,13 @@ class Widget extends App.Controller @disconnectClient() button = 'Reload application' + # convert to html and linkify + message.message = App.Utils.textCleanup( message.message ) + message.message = App.Utils.text2html( message.message ) + new App.SessionMessage( head: message.head - message: message.message + content: message.message keyboard: true backdrop: true close: true diff --git a/test/browser/maintenance_message_test.rb b/test/browser/maintenance_message_test.rb index b8d80dadd..7350a7e05 100644 --- a/test/browser/maintenance_message_test.rb +++ b/test/browser/maintenance_message_test.rb @@ -3,8 +3,12 @@ require 'browser_test_helper' class MaintenanceMessageTest < TestCase def test_websocket - message = 'message 1äöüß ' + rand(99999999999999999).to_s - tests = [ + string = rand(99999999999999999).to_s + title_html = "test #{string}" + title_text = "test #{string}<\/b>" + message_html = "message 1äöüß #{string}\n\n\nhttp://zammad.org" + message_text = "message 1äöüß<\/b> #{string}\n\nhttp:\/\/zammad.org" + tests = [ { :name => 'check #1', :instance1 => browser_instance, @@ -33,13 +37,13 @@ class MaintenanceMessageTest < TestCase :where => :instance1, :execute => 'set', :css => '#content input[name="head"]', - :value => message, + :value => title_html, }, { :where => :instance1, :execute => 'set', :css => '#content textarea[name="message"]', - :value => message, + :value => message_html, }, { :where => :instance1, @@ -50,19 +54,25 @@ class MaintenanceMessageTest < TestCase :execute => 'wait', :value => 5, }, + { + :where => :instance2, + :execute => 'watch_for', + :area => '.modal', + :value => title_text, + }, + { + :where => :instance2, + :execute => 'watch_for', + :area => '.modal', + :value => message_text, + }, { :where => :instance1, :execute => 'match', :css => 'body', - :value => message, + :value => message_text, :match_result => false, }, - { - :where => :instance2, - :execute => 'watch_for', - :area => '.modal', - :value => message, - }, { :where => :instance2, :execute => 'click', @@ -91,13 +101,13 @@ class MaintenanceMessageTest < TestCase :where => :instance1, :execute => 'set', :css => '#content input[name="head"]', - :value => message + ' #2', + :value => title_html + ' #2', }, { :where => :instance1, :execute => 'set', :css => '#content textarea[name="message"]', - :value => message + ' #2', + :value => message_html + ' #2', }, { :where => :instance1, @@ -105,22 +115,24 @@ class MaintenanceMessageTest < TestCase :css => '#content button[type="submit"]', }, { - :execute => 'wait', - :value => 5, + :where => :instance2, + :execute => 'watch_for', + :area => '.modal', + :value => title_text, + }, + { + :where => :instance2, + :execute => 'watch_for', + :area => '.modal', + :value => message_text + ' #2', }, { :where => :instance1, :execute => 'match', :css => 'body', - :value => message + ' #2', + :value => message_text + ' #2', :match_result => false, }, - { - :where => :instance2, - :execute => 'watch_for', - :area => '.modal', - :value => message + ' #2', - }, { :where => :instance2, :execute => 'click', @@ -149,13 +161,13 @@ class MaintenanceMessageTest < TestCase :where => :instance1, :execute => 'set', :css => '#content input[name="head"]', - :value => message + ' #3' , + :value => title_html + ' #3' , }, { :where => :instance1, :execute => 'set', :css => '#content textarea[name="message"]', - :value => message + ' #3', + :value => message_html + ' #3', }, { :where => :instance1, @@ -178,17 +190,23 @@ class MaintenanceMessageTest < TestCase :result => false, }, { - :where => :instance1, - :execute => 'match', - :css => 'body', - :value => message + ' #3', - :match_result => false, + :where => :instance2, + :execute => 'watch_for', + :area => '.modal', + :value => title_text, }, { :where => :instance2, :execute => 'watch_for', :area => '.modal', - :value => message + ' #3', + :value => message_text + ' #3', + }, + { + :where => :instance1, + :execute => 'match', + :css => 'body', + :value => message_text + ' #3', + :match_result => false, }, { :where => :instance2, @@ -201,4 +219,4 @@ class MaintenanceMessageTest < TestCase ] browser_double_test(tests) end -end +end \ No newline at end of file