ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srima...@apache.org
Subject git commit: AMBARI-7840. Slider View: App names should only contain small caps and numbers (Buzhor Denys via srimanth)
Date Fri, 17 Oct 2014 18:12:03 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 de214f22e -> cbccd7354


AMBARI-7840. Slider View: App names should only contain small caps and numbers (Buzhor Denys
via srimanth)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/cbccd735
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cbccd735
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cbccd735

Branch: refs/heads/branch-1.7.0
Commit: cbccd7354b1de1a139c8c28f4b43ce41a3b75857
Parents: de214f2
Author: Srimanth Gunturi <sgunturi@hortonworks.com>
Authored: Fri Oct 17 11:11:19 2014 -0700
Committer: Srimanth Gunturi <sgunturi@hortonworks.com>
Committed: Fri Oct 17 11:11:19 2014 -0700

----------------------------------------------------------------------
 .../createAppWizard/step1_controller.js         |  2 +-
 .../createAppWizard/step1_controller_test.js    | 39 ++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/cbccd735/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js
b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js
index 7802f3a..0aa9893 100644
--- a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js
+++ b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js
@@ -119,7 +119,7 @@ App.CreateAppWizardStep1Controller = Ember.Controller.extend({
     var newAppName = this.get('newApp.name');
     if (newAppName) {
       // new App name should consist only of letters, numbers, '-', '_' and first character
should be a letter
-      if (!/^[A-Za-z][A-Za-z0-9_\-]*$/.test(newAppName)) {
+      if (!/^[a-z][a-z0-9_-]*$/.test(newAppName)) {
         this.set('isNameError', true);
         this.set('nameErrorMessage', Em.I18n.t('wizard.step1.nameFormatError'));
         return false;

http://git-wip-us.apache.org/repos/asf/ambari/blob/cbccd735/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step1_controller_test.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step1_controller_test.js
b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step1_controller_test.js
index cc402e1..fef00be 100644
--- a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step1_controller_test.js
+++ b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step1_controller_test.js
@@ -37,3 +37,42 @@ test('isAppTypesError', function () {
   equal(controller.get('isAppTypesError'), false, 'should be false if app types provided');
 
 });
+
+test('nameValidator', function() {
+  expect(7);
+
+  var tests = [
+    { name: 'Slider', e: true },
+    { name: '_slider', e: true },
+    { name: 'slider*2', e: true },
+    { name: 'slider', e: false },
+    { name: 'slider_1-2_3', e: false }
+  ];
+
+  var controller = this.subject({isNameError: false,
+    store: Em.Object.create({
+      all: function(key) {
+        return {
+          sliderApp: [
+            { name: 'slider2' }
+          ]
+        }[key];
+      }
+    })
+  });
+
+  tests.forEach(function(test) {
+    Em.run(function() {
+      controller.set('newApp', { name: test.name});
+    });
+
+    equal(controller.get('isNameError'), test.e, 'Name `' + test.name + '` is' + (!!test.e
? ' not ' : ' ') + 'valid');
+  });
+
+  Em.run(function() {
+    controller.set('newApp', { name: 'slider2'});
+  })
+
+  equal(controller.get('isNameError'), true, 'Name `slider2` already exist');
+  equal(controller.get('nameErrorMessage'), Em.I18n.t('wizard.step1.nameRepeatError'), 'Error
message should be shown');
+});
\ No newline at end of file


Mime
View raw message