Repository: ambari Updated Branches: refs/heads/trunk 39df32e22 -> a00e7eb24
AMBARI-20557 Versions page: unable to set 'Skip Repository Base URL validation' option. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a00e7eb2 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a00e7eb2 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a00e7eb2 Branch: refs/heads/trunk Commit: a00e7eb246c6063bfd6664781306a5c0b15438e8 Parents: 39df32e Author: ababiichuk <[email protected]> Authored: Fri Mar 24 13:47:24 2017 +0200 Committer: ababiichuk <[email protected]> Committed: Fri Mar 24 13:47:24 2017 +0200 ---------------------------------------------------------------------- .../stack_upgrade/upgrade_version_box_view.js | 2 +- .../upgrade_version_box_view_test.js | 124 +++++++++++++++---- 2 files changed, 99 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/a00e7eb2/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js index a714149..081d7cd 100644 --- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js +++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js @@ -370,7 +370,7 @@ App.UpgradeVersionBoxView = Em.View.extend({ repoBinding: 'parentView.content', checkboxClassNames: ["align-checkbox"], change: function() { - this.get('parentView.repo').forEach(function(os) { + this.get('repo.operatingSystems').forEach(function(os) { os.get('repositories').forEach(function(repo) { repo.set('skipValidation', this.get('checked')); }, this); http://git-wip-us.apache.org/repos/asf/ambari/blob/a00e7eb2/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js index 58067a2..153b66f 100644 --- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js +++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js @@ -249,35 +249,107 @@ describe('App.UpgradeVersionBoxView', function () { }); describe("#editRepositories()", function () { - var cases = [ - { - isRepoUrlsEditDisabled: true, - popupShowCallCount: 0, - title: 'edit repo URLS disabled, popup shouldn\'t be shown' - }, - { - isRepoUrlsEditDisabled: false, - popupShowCallCount: 1, - title: 'edit repo URLS enabled, popup should be shown' - } - ]; - beforeEach(function () { - sinon.stub(App.RepositoryVersion, 'find').returns(Em.Object.create({ - operatingSystems: [] - })); - sinon.stub(App.ModalPopup, 'show', Em.K); - }); - afterEach(function () { - App.RepositoryVersion.find.restore(); - App.ModalPopup.show.restore(); + + describe('popup display', function () { + var cases = [ + { + isRepoUrlsEditDisabled: true, + popupShowCallCount: 0, + title: 'edit repo URLS disabled, popup shouldn\'t be shown' + }, + { + isRepoUrlsEditDisabled: false, + popupShowCallCount: 1, + title: 'edit repo URLS enabled, popup should be shown' + } + ]; + beforeEach(function () { + sinon.stub(App.RepositoryVersion, 'find').returns(Em.Object.create({ + operatingSystems: [] + })); + sinon.stub(App.ModalPopup, 'show', Em.K); + }); + afterEach(function () { + App.RepositoryVersion.find.restore(); + App.ModalPopup.show.restore(); + }); + cases.forEach(function (item) { + it(item.title, function () { + view.reopen({ + isRepoUrlsEditDisabled: item.isRepoUrlsEditDisabled + }); + view.editRepositories(); + expect(App.ModalPopup.show.callCount).to.equal(item.popupShowCallCount); + }); + }); }); - cases.forEach(function (item) { - it(item.title, function () { + + describe('skip base URL validation', function () { + var checkbox, + cases = [ + { + checked: true, + skipValidation: true, + title: 'option is enabled' + }, + { + checked: false, + skipValidation: false, + title: 'option is disabled' + } + ]; + beforeEach(function () { + sinon.stub(App.RepositoryVersion, 'find').returns(Em.Object.create({ + operatingSystems: [ + Em.Object.create({ + repositories: [ + Em.Object.create(), + Em.Object.create({ + skipValidation: true + }), + Em.Object.create({ + skipValidation: false + }) + ] + }), + Em.Object.create({ + repositories: [ + Em.Object.create(), + Em.Object.create({ + skipValidation: true + }), + Em.Object.create({ + skipValidation: false + }) + ] + }) + ] + })); + sinon.stub(App.ModalPopup, 'show', function (popupOptions) { + var body = popupOptions.bodyClass.create(); + return body.get('skipCheckBox').create({ + parentView: body + }); + }); view.reopen({ - isRepoUrlsEditDisabled: item.isRepoUrlsEditDisabled + isRepoUrlsEditDisabled: false + }); + checkbox = view.editRepositories(); + }); + afterEach(function () { + App.RepositoryVersion.find.restore(); + App.ModalPopup.show.restore(); + }); + cases.forEach(function (item) { + it(item.title, function () { + checkbox.set('checked', item.checked); + checkbox.change(); + var reposByOS = checkbox.get('repo.operatingSystems').mapProperty('repositories'), + result = reposByOS.map(function (repos) { + return repos.everyProperty('skipValidation', item.skipValidation); + }); + expect(result).to.eql([true, true]); }); - view.editRepositories(); - expect(App.ModalPopup.show.callCount).to.equal(item.popupShowCallCount); }); }); });
