Repository: ambari Updated Branches: refs/heads/trunk 5306e0d20 -> 45c7b27ed
AMBARI-11969. Clicking "open" on a task in RU dialog does not format like it does in ops dialog (akovalenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/45c7b27e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/45c7b27e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/45c7b27e Branch: refs/heads/trunk Commit: 45c7b27ed9c6d005a3dd5a7a5f84ba56bfc4621a Parents: 5306e0d Author: Aleksandr Kovalenko <[email protected]> Authored: Wed Jun 17 14:56:15 2015 +0300 Committer: Aleksandr Kovalenko <[email protected]> Committed: Wed Jun 17 19:26:54 2015 +0300 ---------------------------------------------------------------------- .../admin/stack_upgrade/upgrade_task_view.js | 9 ++++-- .../stack_upgrade/upgrade_task_view_test.js | 29 +++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/45c7b27e/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js index 798f416..b289ce1 100644 --- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js +++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js @@ -119,9 +119,12 @@ App.upgradeTaskView = Em.View.extend({ * @param {string} log */ openLogWindow: function(log) { - var newWindow = window.open(); - var newDocument = newWindow.document; - newDocument.write(log); + var newWindow = window.open(), + newDocument = newWindow.document, + outputWrapper = newDocument.createElement('pre'), + output = newDocument.createTextNode(log); + outputWrapper.appendChild(output); + newDocument.body.appendChild(outputWrapper); newDocument.close(); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/45c7b27e/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js index 00fee03..de578a1 100644 --- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js +++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js @@ -119,26 +119,41 @@ describe('App.upgradeTaskView', function () { }); describe("#openLogWindow()", function () { - var mockWindow = { - document: { - write: Em.K, - close: Em.K - } - }; + var mockAppendChild = { + appendChild: Em.K + }, + mockWindow = { + document: { + write: Em.K, + close: Em.K, + createElement: function () { + return mockAppendChild; + }, + createTextNode: Em.K, + body: mockAppendChild + } + }; before(function () { sinon.stub(window, 'open').returns(mockWindow); sinon.spy(mockWindow.document, 'write'); sinon.spy(mockWindow.document, 'close'); + sinon.spy(mockWindow.document, 'createElement'); + sinon.spy(mockWindow.document, 'createTextNode'); + sinon.spy(mockAppendChild, 'appendChild'); }); after(function () { window.open.restore(); mockWindow.document.write.restore(); mockWindow.document.close.restore(); + mockWindow.document.createElement.restore(); + mockWindow.document.createTextNode.restore(); }); it("", function () { view.openLogWindow('log'); expect(window.open.calledOnce).to.be.true; - expect(mockWindow.document.write.calledWith('log')).to.be.true; + expect(mockWindow.document.createElement.calledWith('pre')).to.be.true; + expect(mockWindow.document.createTextNode.calledWith('log')).to.be.true; + expect(mockAppendChild.appendChild.calledTwice).to.be.true; expect(mockWindow.document.close.calledOnce).to.be.true; }); });
