couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject fauxton commit: updated refs/heads/master to e0201f2
Date Mon, 02 Feb 2015 12:29:14 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master f6b258c2a -> e0201f235


Fix changes keeping filter in memory

This fixes COUCHDB-2563


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

Branch: refs/heads/master
Commit: e0201f235e6ce49d93c86782656138d7e2b3ba53
Parents: f6b258c
Author: Garren Smith <garren.smith@gmail.com>
Authored: Mon Feb 2 11:40:22 2015 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Mon Feb 2 14:28:54 2015 +0200

----------------------------------------------------------------------
 app/addons/documents/tests/views-changesSpec.js | 32 +++++++++++++++-----
 app/addons/documents/views-changes.js           |  4 +--
 app/addons/fauxton/components.js                |  8 ++---
 test/mocha/testUtils.js                         |  5 ++-
 4 files changed, 30 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e0201f23/app/addons/documents/tests/views-changesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/views-changesSpec.js b/app/addons/documents/tests/views-changesSpec.js
index 36669ad..91c372c 100644
--- a/app/addons/documents/tests/views-changesSpec.js
+++ b/app/addons/documents/tests/views-changesSpec.js
@@ -19,22 +19,25 @@ define([
       viewSandbox;
 
   describe('Documents Changes', function () {
-    var model = new Databases.Model({id: 'foo'}),
+    var model,
         filteredView,
-        view,
-        handlerSpy;
+        handlerSpy,
+        view;
 
-    model.buildChanges();
-
-    handlerSpy = sinon.spy(Views.Changes.prototype, 'toggleJson');
 
     beforeEach(function (done) {
       var database = new Databases.Model({id: 'bla'});
+
+      model = new Databases.Model({id: 'foo'});
+      model.buildChanges();
+
       database.buildChanges({descending: 'true', limit: '100', include_docs: 'true'} );
       filteredView = new Views.Changes({
         model: database
       });
 
+      handlerSpy = sinon.spy(Views.Changes.prototype, 'toggleJson');
+
       view = new Views.Changes({
         model: model,
         useRAF: false
@@ -44,9 +47,23 @@ define([
     });
 
     afterEach(function () {
+      handlerSpy.restore();
+      view.afterRender.restore && view.afterRender.restore();
       viewSandbox.remove();
     });
 
+    it('does not keep filters in memory', function () {
+      view.filters.push('cat');
+      view = new Views.Changes({
+        model: model,
+        useRAF: false
+      });
+
+      view.filters.push('mat');
+
+      assert.deepEqual(view.filters, ['mat']);
+    });
+
     it('filter false in case of deleted documents in the changes feed', function () {
       filteredView.filters = [false];
       var res = filteredView.createFilteredData([
@@ -66,7 +83,7 @@ define([
     it('rerenders on the sync event', function () {
       var spy = sinon.spy(view, 'afterRender');
       model.changes.trigger('sync');
-      view.afterRender.restore();
+
       assert.ok(spy.calledOnce);
     });
 
@@ -74,7 +91,6 @@ define([
       var spy = sinon.spy(view, 'afterRender');
       model.changes.trigger('cachesync');
       assert.ok(spy.calledOnce);
-      view.afterRender.restore();
     });
   });
 });

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e0201f23/app/addons/documents/views-changes.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/views-changes.js b/app/addons/documents/views-changes.js
index 22e7c18..b58a78d 100644
--- a/app/addons/documents/views-changes.js
+++ b/app/addons/documents/views-changes.js
@@ -48,6 +48,7 @@ function(app, FauxtonAPI, Components, prettify, ZeroClipboard) {
     initialize: function () {
       this.listenTo(this.model.changes, 'sync', this.render);
       this.listenTo(this.model.changes, 'cachesync', this.render);
+      this.filters = [];
     },
 
     events: {
@@ -89,10 +90,7 @@ function(app, FauxtonAPI, Components, prettify, ZeroClipboard) {
     },
 
     createFilteredData: function (json) {
-      var that = this;
-
       return _.reduce(this.filters, function (elements, filter) {
-
         return _.filter(elements, function (element) {
           var match = false;
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e0201f23/app/addons/fauxton/components.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/components.js b/app/addons/fauxton/components.js
index 7ab30fc..c6f307d 100644
--- a/app/addons/fauxton/components.js
+++ b/app/addons/fauxton/components.js
@@ -607,7 +607,7 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) {
   Components.DbSearchTypeahead = Components.Typeahead.extend({
     initialize: function (options) {
       this.dbLimit = options.dbLimit || 30;
-      if (options.filter) { 
+      if (options.filter) {
         this.resultFilter = options.resultFilter;
       }
       _.bindAll(this);
@@ -679,9 +679,7 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) {
   });
 
   Components.FilteredView = FauxtonAPI.View.extend({
-    filters: [],
     createFilteredData: function (json) {
-      var that = this;
       return _.reduce(this.filters, function (elements, filter) {
         return _.filter(elements, function (element) {
           var match = false;
@@ -1130,7 +1128,7 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) {
   var routeObjectSpinner;
 
   FauxtonAPI.RouteObject.on('beforeEstablish', function (routeObject) {
-    if (!routeObject.disableLoader){ 
+    if (!routeObject.disableLoader){
       var opts = {
         lines: 16, // The number of lines to draw
         length: 8, // The length of each line
@@ -1176,7 +1174,7 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) {
   FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
     removeRouteObjectSpinner();
 
-    if (!view.disableLoader){ 
+    if (!view.disableLoader){
       var opts = {
         lines: 16, // The number of lines to draw
         length: 8, // The length of each line

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e0201f23/test/mocha/testUtils.js
----------------------------------------------------------------------
diff --git a/test/mocha/testUtils.js b/test/mocha/testUtils.js
index d46193f..6313520 100644
--- a/test/mocha/testUtils.js
+++ b/test/mocha/testUtils.js
@@ -32,7 +32,7 @@ function(FauxtonAPI, chai, sinonChai) {
       this.views.push(view);
       this.$el.append(view.el);
       view.render();
-      if (done) { 
+      if (done) {
         view.promise().done(function () { done(); });
       }
       return view;
@@ -40,7 +40,7 @@ function(FauxtonAPI, chai, sinonChai) {
 
     remove: function () {
       _.each(this.views, function (view) {
-        view.removeView();
+        view.remove();
       }, this);
     }
   });
@@ -51,4 +51,3 @@ function(FauxtonAPI, chai, sinonChai) {
     ViewSandbox: ViewSandbox
   };
 });
-


Mime
View raw message