AMBARI-15687. Incorrect Hive DB recommendations being made on Safari browser (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/891addc7 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/891addc7 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/891addc7 Branch: refs/heads/trunk Commit: 891addc7d134cc1edf710b2b524764f3c867726c Parents: 0300a6a Author: Alex Antonenko <[email protected]> Authored: Mon Apr 4 19:45:20 2016 +0300 Committer: Alex Antonenko <[email protected]> Committed: Tue Apr 5 01:21:54 2016 +0300 ---------------------------------------------------------------------- ambari-web/app/views/common/controls_view.js | 2 +- .../test/views/common/controls_view_test.js | 113 ++++++++++++++++--- 2 files changed, 97 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/891addc7/ambari-web/app/views/common/controls_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/controls_view.js b/ambari-web/app/views/common/controls_view.js index 661ef54..3ca0eda 100644 --- a/ambari-web/app/views/common/controls_view.js +++ b/ambari-web/app/views/common/controls_view.js @@ -769,8 +769,8 @@ App.ServiceConfigRadioButton = Ember.Checkbox.extend(App.SupportsDependentConfig // in Service Config page if (this.get('clicked')) { Em.run.next(this, function() { - this.sendRequestRorDependentConfigs(this.get('parentView.serviceConfig')); this.set('parentView.serviceConfig.value', this.get('value')); + this.sendRequestRorDependentConfigs(this.get('parentView.serviceConfig')); this.set('clicked', false); this.updateForeignKeys(); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/891addc7/ambari-web/test/views/common/controls_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/controls_view_test.js b/ambari-web/test/views/common/controls_view_test.js index 07a80dd..dca7911 100644 --- a/ambari-web/test/views/common/controls_view_test.js +++ b/ambari-web/test/views/common/controls_view_test.js @@ -444,6 +444,21 @@ describe('App.ServiceConfigRadioButtons', function () { describe('App.ServiceConfigRadioButton', function () { + var view; + + beforeEach(function () { + view = App.ServiceConfigRadioButton.create({ + parentView: Em.Object.create({ + serviceConfig: Em.Object.create() + }), + controller: Em.Object.create({ + wizardController: Em.Object.create({ + name: null + }) + }) + }) + }); + describe('#disabled', function () { var cases = [ @@ -487,35 +502,99 @@ describe('App.ServiceConfigRadioButton', function () { cases.forEach(function (item) { it(item.title, function () { - var view = App.ServiceConfigRadioButton.create({ - parentView: Em.Object.create({ - serviceConfig: Em.Object.create() - }), - controller: Em.Object.create({ - wizardController: Em.Object.create({ - name: null - }) - }) + view.setProperties({ + 'value': item.value, + 'controller.wizardController.name': item.wizardControllerName, + 'parentView.serviceConfig.isEditable': true }); - view.set('value', item.value); - view.set('controller.wizardController.name', item.wizardControllerName); - view.set('parentView.serviceConfig.isEditable', true); expect(view.get('disabled')).to.equal(item.disabled); }); }); it('parent view is disabled', function () { - var view = App.ServiceConfigRadioButton.create({ - parentView: Em.Object.create({ - serviceConfig: Em.Object.create() - }) - }); view.set('parentView.serviceConfig.isEditable', false); expect(view.get('disabled')).to.be.true; }); }); + describe('#onChecked', function () { + + var cases = [ + { + clicked: true, + value: 'v1', + sendRequestRorDependentConfigsCallCount: 1, + updateForeignKeysCallCount: 1, + title: 'invoked with click' + }, + { + clicked: false, + value: 'v0', + sendRequestRorDependentConfigsCallCount: 0, + updateForeignKeysCallCount: 0, + title: 'not invoked with click' + } + ]; + + cases.forEach(function (item) { + + describe(item.title, function () { + + beforeEach(function () { + sinon.stub(Em.run, 'next', function (context, callback) { + callback.call(context); + }); + sinon.stub(view, 'sendRequestRorDependentConfigs', Em.K); + sinon.stub(view, 'updateForeignKeys', Em.K); + sinon.stub(view, 'updateCheck', Em.K); + view.setProperties({ + 'clicked': item.clicked, + 'parentView.serviceConfig.value': 'v0', + 'value': 'v1' + }); + view.propertyDidChange('checked'); + }); + + afterEach(function () { + Em.run.next.restore(); + view.sendRequestRorDependentConfigs.restore(); + view.updateForeignKeys.restore(); + view.updateCheck.restore(); + }); + + it('property value', function () { + expect(view.get('parentView.serviceConfig.value')).to.equal(item.value); + }); + + it('dependent configs request', function () { + expect(view.sendRequestRorDependentConfigs.callCount).to.equal(item.sendRequestRorDependentConfigsCallCount); + }); + + if (item.sendRequestRorDependentConfigsCallCount) { + it('config object for dependent configs request', function () { + expect(view.sendRequestRorDependentConfigs.firstCall.args).to.eql([ + Em.Object.create({ + value: item.value + }) + ]); + }); + } + + it('clicked flag reset', function () { + expect(view.get('clicked')).to.be.false; + }); + + it('update foreign keys', function () { + expect(view.updateForeignKeys.callCount).to.equal(item.updateForeignKeysCallCount); + }); + + }); + + }); + + }); + }); describe('App.CheckDBConnectionView', function () {
