You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2015/06/26 16:50:41 UTC
[2/2] ambari git commit: AMBARI-12164 Wrong Dependent Configurations
message. (atkach)
AMBARI-12164 Wrong Dependent Configurations message. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c177f465
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c177f465
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c177f465
Branch: refs/heads/trunk
Commit: c177f46577251ec32c20cee8d491d3d2a32dfa9f
Parents: e01a0ba
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Fri Jun 26 15:14:22 2015 +0300
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Fri Jun 26 17:46:19 2015 +0300
----------------------------------------------------------------------
.../mixins/common/configs/enhanced_configs.js | 11 ++--
.../common/configs/enhanced_configs_test.js | 61 ++++++++++++++++++++
2 files changed, 67 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/c177f465/ambari-web/app/mixins/common/configs/enhanced_configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/enhanced_configs.js b/ambari-web/app/mixins/common/configs/enhanced_configs.js
index fdfb45b..9522af4 100644
--- a/ambari-web/app/mixins/common/configs/enhanced_configs.js
+++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js
@@ -69,11 +69,12 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
* @type {string}
*/
dependenciesMessage: function() {
- var changedServices = this.get('changedProperties').filterProperty('saveRecommended', true).mapProperty('serviceName').uniq();
- var cfgLen = this.get('changedProperties').filterProperty('saveRecommended', true).length === 1 ? 'singular' : 'plural';
- var sLen = changedServices.length === 1 ? 'singular' : 'plural';
- return Em.I18n.t('popup.dependent.configs.dependencies.config.' + cfgLen).format(this.get('changedProperties.length'))
- + Em.I18n.t('popup.dependent.configs.dependencies.service.' + sLen).format(changedServices.length);
+ var changedProperties = this.get('changedProperties').filterProperty('saveRecommended');
+ var changedServices = changedProperties.mapProperty('serviceName').uniq();
+ var cfgLenSuffix = changedProperties.length === 1 ? 'singular' : 'plural';
+ var sLenSuffix = changedServices.length === 1 ? 'singular' : 'plural';
+ return Em.I18n.t('popup.dependent.configs.dependencies.config.' + cfgLenSuffix).format(changedProperties.length)
+ + Em.I18n.t('popup.dependent.configs.dependencies.service.' + sLenSuffix).format(changedServices.length);
}.property('changedProperties.length'),
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/c177f465/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
index c085e2c..6c4b6d7 100644
--- a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
+++ b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
@@ -94,5 +94,66 @@ describe('App.EnhancedConfigsMixin', function() {
expect(instanceObject.buildConfigGroupJSON.bind(instanceObject)).to.throw(Error, 'configGroup can\'t be null');
});
});
+
+ describe("#dependenciesMessage", function () {
+ var mixinInstance = mixinObject.create({
+ changedProperties: []
+ });
+ it("no properties changed", function() {
+ mixinInstance.set('changedProperties', []);
+ mixinInstance.propertyDidChange('dependenciesMessage');
+ expect(mixinInstance.get('dependenciesMessage')).to.equal(
+ Em.I18n.t('popup.dependent.configs.dependencies.config.plural').format(0) +
+ Em.I18n.t('popup.dependent.configs.dependencies.service.plural').format(0)
+ )
+ });
+ it("single property changed", function() {
+ mixinInstance.set('changedProperties', [
+ Em.Object.create({
+ saveRecommended: true,
+ serviceName: 'S1'
+ })
+ ]);
+ mixinInstance.propertyDidChange('dependenciesMessage');
+ expect(mixinInstance.get('dependenciesMessage')).to.equal(
+ Em.I18n.t('popup.dependent.configs.dependencies.config.singular').format(1) +
+ Em.I18n.t('popup.dependent.configs.dependencies.service.singular').format(1)
+ )
+ });
+ it("two properties changed", function() {
+ mixinInstance.set('changedProperties', [
+ Em.Object.create({
+ saveRecommended: true,
+ serviceName: 'S1'
+ }),
+ Em.Object.create({
+ saveRecommended: true,
+ serviceName: 'S1'
+ })
+ ]);
+ mixinInstance.propertyDidChange('dependenciesMessage');
+ expect(mixinInstance.get('dependenciesMessage')).to.equal(
+ Em.I18n.t('popup.dependent.configs.dependencies.config.plural').format(2) +
+ Em.I18n.t('popup.dependent.configs.dependencies.service.singular').format(1)
+ )
+ });
+ it("two properties changed, from different services", function() {
+ mixinInstance.set('changedProperties', [
+ Em.Object.create({
+ saveRecommended: true,
+ serviceName: 'S1'
+ }),
+ Em.Object.create({
+ saveRecommended: true,
+ serviceName: 'S2'
+ })
+ ]);
+ mixinInstance.propertyDidChange('dependenciesMessage');
+ expect(mixinInstance.get('dependenciesMessage')).to.equal(
+ Em.I18n.t('popup.dependent.configs.dependencies.config.plural').format(2) +
+ Em.I18n.t('popup.dependent.configs.dependencies.service.plural').format(2)
+ )
+ });
+ });
});