couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [39/50] [abbrv] fauxton commit: updated refs/heads/import-master to b32c617
Date Tue, 01 Apr 2014 09:14:55 GMT
Fauxton: Config test fixes


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

Branch: refs/heads/import-master
Commit: c2bd589965c46d0850fb03635f20a3f9dc32db81
Parents: 4cca730
Author: Robert Kowalski <rok@kowalski.gd>
Authored: Fri Mar 21 17:49:15 2014 +0100
Committer: suelockwood <deathbear@apache.org>
Committed: Fri Mar 21 13:35:43 2014 -0400

----------------------------------------------------------------------
 app/addons/config/tests/resourcesSpec.js | 20 +++++++++++---
 app/addons/config/views.js               | 39 ++++++++++++++-------------
 2 files changed, 36 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/c2bd5899/app/addons/config/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/config/tests/resourcesSpec.js b/app/addons/config/tests/resourcesSpec.js
index c78bc85..1cc9e62 100644
--- a/app/addons/config/tests/resourcesSpec.js
+++ b/app/addons/config/tests/resourcesSpec.js
@@ -28,7 +28,10 @@ define([
       });
 
       tabMenu = new Views.TableRow({
-        model: optionModel
+        model: optionModel,
+        uniqueName: function () {
+          return false;
+        }
       });
     });
 
@@ -47,8 +50,12 @@ define([
         var renderSpy = sinon.stub(tabMenu, 'render');
         var saveSpy = sinon.stub(optionModel, 'save');
 
-        tabMenu.$('.js-edit-value').trigger('dblclick');
-        tabMenu.$('.js-save-value').trigger('click');
+        var $fields = tabMenu.$('.js-edit-value').filter(function (el) {
+          return $(this).find('[name="value"]').length;
+        });
+
+        $fields.find('.js-edit-value').trigger('dblclick');
+        $fields.find('.js-save-value').trigger('click');
 
         assert.ok(renderSpy.calledOnce);
         assert.ok(saveSpy.calledOnce);
@@ -60,7 +67,12 @@ define([
 
         var e = $.Event("keyup");
         e.keyCode = 13;
-        tabMenu.$('.js-value-input').trigger(e);
+
+        var $fields = tabMenu.$('.js-edit-value').filter(function (el) {
+          return $(this).find('[name="value"]').length;
+        });
+
+        $fields.find('.js-value-input').trigger(e);
 
         assert.ok(renderSpy.calledOnce);
         assert.ok(saveSpy.calledOnce);

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/c2bd5899/app/addons/config/views.js
----------------------------------------------------------------------
diff --git a/app/addons/config/views.js b/app/addons/config/views.js
index 8453d90..7952182 100644
--- a/app/addons/config/views.js
+++ b/app/addons/config/views.js
@@ -80,28 +80,29 @@ function(app, FauxtonAPI, Config, Components) {
       return {option: this.model.toJSON()};
     },
     saveAndRender: function (event) {
-      var options = {};
-        $input = this.$(event.currentTarget).parents('td').find(".js-value-input");
-        options[$input.attr('name')] = $input.val();
-
-        if ($input.attr('name')==='name'){
-          if (this.uniqueName($input.val())){
-            this.error = FauxtonAPI.addNotification({
-                msg: "This config already exists, enter a unique name",
-                type: "error",
-                clear: true
-            });
-          } else {
-            var newModel = this.model.clone();
-              newModel.save(options);
-              this.model.destroy();
-              this.model = newModel;
-              this.render();
-          }
+      var options = {},
+          $input = this.$(event.currentTarget).parents('td').find(".js-value-input");
+
+      options[$input.attr('name')] = $input.val();
+
+      if ($input.attr('name')==='name'){
+        if (this.uniqueName($input.val())){
+          this.error = FauxtonAPI.addNotification({
+            msg: "This config already exists, enter a unique name",
+            type: "error",
+            clear: true
+          });
         } else {
+          var newModel = this.model.clone();
+          newModel.save(options);
+          this.model.destroy();
+          this.model = newModel;
+          this.render();
+        }
+      } else {
         this.model.save(options);
         this.render();
-        }
+      }
     }
 
   });


Mime
View raw message