couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benk...@apache.org
Subject fauxton commit: updated refs/heads/master to 010557e
Date Fri, 25 Sep 2015 20:13:56 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 99dfd3f5c -> 010557ecf


Fix for editing View not showing correct content

There's a bug where if you edit one index, then edit a second,
you still see the Map Function from the first view. This PR does an
explicit reset every time you edit a view.


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

Branch: refs/heads/master
Commit: 010557ecfbcddb95f7d507f22785a048bb2eebb0
Parents: 99dfd3f
Author: Ben Keen <ben.keen@gmail.com>
Authored: Fri Sep 25 10:05:52 2015 -0700
Committer: Ben Keen <ben.keen@gmail.com>
Committed: Fri Sep 25 13:13:38 2015 -0700

----------------------------------------------------------------------
 app/addons/documents/index-editor/actions.js    |  4 ++
 .../documents/index-editor/actiontypes.js       |  1 +
 app/addons/documents/index-editor/stores.js     |  8 +++
 app/addons/documents/routes-index-editor.js     |  2 +
 .../documents/tests/nightwatch/viewEdit.js      | 68 ++++++++++++++++++++
 5 files changed, 83 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/010557ec/app/addons/documents/index-editor/actions.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/index-editor/actions.js b/app/addons/documents/index-editor/actions.js
index b5250a0..294b02d 100644
--- a/app/addons/documents/index-editor/actions.js
+++ b/app/addons/documents/index-editor/actions.js
@@ -76,6 +76,10 @@ function (app, FauxtonAPI, Documents, ActionTypes, IndexResultsActions)
{
       });
     },
 
+    clearIndex: function () {
+      FauxtonAPI.dispatch({ type: ActionTypes.CLEAR_INDEX });
+    },
+
     fetchDesignDocsBeforeEdit: function (options) {
       options.designDocs.fetch({reset: true}).then(function () {
         this.editIndex(options);

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/010557ec/app/addons/documents/index-editor/actiontypes.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/index-editor/actiontypes.js b/app/addons/documents/index-editor/actiontypes.js
index e13c57a..43fe021 100644
--- a/app/addons/documents/index-editor/actiontypes.js
+++ b/app/addons/documents/index-editor/actiontypes.js
@@ -12,6 +12,7 @@
 
 define([], function () {
   return {
+    CLEAR_INDEX: 'CLEAR_INDEX',
     EDIT_INDEX: 'EDIT_INDEX',
     EDIT_NEW_INDEX: 'EDIT_NEW_INDEX',
     SELECT_REDUCE_CHANGE: 'SELECT_REDUCE_CHANGE',

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/010557ec/app/addons/documents/index-editor/stores.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/index-editor/stores.js b/app/addons/documents/index-editor/stores.js
index 3f7bb7d..9615451 100644
--- a/app/addons/documents/index-editor/stores.js
+++ b/app/addons/documents/index-editor/stores.js
@@ -24,6 +24,10 @@ function (FauxtonAPI, ActionTypes) {
     defaultReduce: 'function (keys, values, rereduce) {\n  if (rereduce) {\n    return sum(values);\n
 } else {\n    return values.length;\n  }\n}',
 
     initialize: function () {
+      this.reset();
+    },
+
+    reset: function () {
       this._designDocs = [];
       this._isLoading = true;
       this._view = { reduce: '', map: this.defaultMap };
@@ -175,6 +179,10 @@ function (FauxtonAPI, ActionTypes) {
 
     dispatch: function (action) {
       switch (action.type) {
+        case ActionTypes.CLEAR_INDEX:
+          this.reset();
+        break;
+
         case ActionTypes.EDIT_INDEX:
           this.editIndex(action.options);
           this.triggerChange();

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/010557ec/app/addons/documents/routes-index-editor.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/routes-index-editor.js b/app/addons/documents/routes-index-editor.js
index 450c4c1..52c5da5 100644
--- a/app/addons/documents/routes-index-editor.js
+++ b/app/addons/documents/routes-index-editor.js
@@ -93,6 +93,8 @@ function (app, FauxtonAPI, Helpers, BaseRoute, Documents, IndexEditorComponents,
         }
       });
 
+      ActionsIndexEditor.clearIndex();
+
       IndexResultsActions.newResultsList({
         collection: this.indexedDocs,
         isListDeletable: false,

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/010557ec/app/addons/documents/tests/nightwatch/viewEdit.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/viewEdit.js b/app/addons/documents/tests/nightwatch/viewEdit.js
index 96cf409..ef9526f 100644
--- a/app/addons/documents/tests/nightwatch/viewEdit.js
+++ b/app/addons/documents/tests/nightwatch/viewEdit.js
@@ -75,6 +75,74 @@ module.exports = {
     .end();
   },
 
+  'Edits two design docs to confirm Map Editor correct on second': function (client) {
+    /*jshint multistr: true */
+    var waitTime = client.globals.maxWaitTime,
+      newDatabaseName = client.globals.testDatabaseName,
+      baseUrl = client.globals.test_settings.launch_url,
+      dropDownElement = '#header-dropdown-menu';
+
+    client
+      .createDatabase(newDatabaseName)
+      .populateDatabase(newDatabaseName)
+      .loginToGUI()
+
+      // create the first view
+      .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
+      .waitForElementPresent(dropDownElement, waitTime, false)
+      .clickWhenVisible(dropDownElement + ' a')
+      .clickWhenVisible(dropDownElement + ' a[href*="new_view"]')
+      .waitForElementVisible('#new-ddoc', waitTime, false)
+      .setValue('#new-ddoc', 'view1-name')
+      .clearValue('#index-name')
+      .setValue('#index-name', 'view1')
+      .clickWhenVisible('#reduce-function-selector')
+      .keys(['\uE013', '\uE013', '\uE013', '\uE013', '\uE006'])
+      .execute('\
+        var editor = ace.edit("map-function");\
+        editor.getSession().setValue("function (doc) { emit(doc._id, 100); }");\
+      ')
+      .execute('$("#save-view")[0].scrollIntoView();')
+      .clickWhenVisible('#save-view')
+      .checkForDocumentCreated('_design/view1-name')
+      .waitForElementPresent('.btn.btn-danger.delete', waitTime, false)
+
+      // create the second view
+      .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
+      .waitForElementPresent(dropDownElement, waitTime, false)
+      .clickWhenVisible(dropDownElement + ' a')
+      .clickWhenVisible(dropDownElement + ' a[href*="new_view"]')
+      .waitForElementVisible('#new-ddoc', waitTime, false)
+      .setValue('#new-ddoc', 'view2-name')
+      .clearValue('#index-name')
+      .setValue('#index-name', 'view2')
+      .clickWhenVisible('#reduce-function-selector')
+      .keys(['\uE013', '\uE013', '\uE013', '\uE013', '\uE006'])
+      .execute('\
+        var editor = ace.edit("map-function");\
+        editor.getSession().setValue("function (doc) { emit(doc._id, 200); }");\
+      ')
+      .execute('$("#save-view")[0].scrollIntoView();')
+      .clickWhenVisible('#save-view')
+      .checkForDocumentCreated('_design/view2-name')
+      .waitForElementPresent('.btn.btn-danger.delete', waitTime, false)
+
+      // go back to the all docs page to ensure a page reload when we return to the Edit
View page
+      .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
+      .waitForElementPresent(dropDownElement, waitTime, false)
+
+      // now redirect back to first view and confirm the fields are all populated properly
+      .url(baseUrl + '/#/database/' + newDatabaseName + '/_design/view1-name/_view/view1')
+      .waitForElementVisible('#save-view', waitTime, false)
+      .execute(function () {
+        var editor = window.ace.edit("map-function");
+        return editor.getSession().getValue();
+      }, [], function (resp) {
+        this.assert.equal(resp.value, 'function (doc) { emit(doc._id, 100); }');
+      })
+      .end();
+  },
+
   'Query Options are kept after a new reduce method is chosen': function (client) {
     /*jshint multistr: true */
     var waitTime = client.globals.maxWaitTime,


Mime
View raw message