Repository: ambari
Updated Branches:
  refs/heads/trunk 0ab58755d -> 75f78825b


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/75f78825
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/75f78825
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/75f78825

Branch: refs/heads/trunk
Commit: 75f78825bbdf7f73feb51aa60326b008f6cfb551
Parents: 0ab5875
Author: Srimanth Gunturi <sgunt...@hortonworks.com>
Authored: Fri Oct 17 11:11:19 2014 -0700
Committer: Srimanth Gunturi <sgunt...@hortonworks.com>
Committed: Fri Oct 17 11:12:18 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/75f78825/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/75f78825/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

Reply via email to