You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by de...@apache.org on 2014/03/21 18:35:49 UTC
couchdb commit: updated refs/heads/master to 35390c8
Repository: couchdb
Updated Branches:
refs/heads/master f2153c0f9 -> 35390c833
Fauxton: Config test fixes
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/35390c83
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/35390c83
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/35390c83
Branch: refs/heads/master
Commit: 35390c833333a7b5935b34da47be9a1696c845f7
Parents: f2153c0
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Fri Mar 21 17:49:15 2014 +0100
Committer: suelockwood <de...@apache.org>
Committed: Fri Mar 21 13:35:43 2014 -0400
----------------------------------------------------------------------
.../app/addons/config/tests/resourcesSpec.js | 20 ++++++++--
src/fauxton/app/addons/config/views.js | 39 ++++++++++----------
2 files changed, 36 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35390c83/src/fauxton/app/addons/config/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/tests/resourcesSpec.js b/src/fauxton/app/addons/config/tests/resourcesSpec.js
index c78bc85..1cc9e62 100644
--- a/src/fauxton/app/addons/config/tests/resourcesSpec.js
+++ b/src/fauxton/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/blob/35390c83/src/fauxton/app/addons/config/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/views.js b/src/fauxton/app/addons/config/views.js
index 8453d90..7952182 100644
--- a/src/fauxton/app/addons/config/views.js
+++ b/src/fauxton/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();
- }
+ }
}
});