Browse Source

more tests for core services

Rafał Pitoń 9 years ago
parent
commit
cec7d032e0

+ 0 - 1
makemessages

@@ -4,6 +4,5 @@ cd misago
 echo "Extracting messages from .py and .html files..."
 echo "Extracting messages from .py and .html files..."
 django-admin.py makemessages -l $1 --ignore=frontend/*
 django-admin.py makemessages -l $1 --ignore=frontend/*
 
 
-
 echo "Extracting messages from js files..."
 echo "Extracting messages from js files..."
 django-admin.py makemessages -l $1 -d djangojs --ignore=frontend/bower_components/* --ignore=frontend/node_modules/* --ignore=frontend/dist/* --ignore=frontend/static/* --ignore=frontend/test/*  --ignore=frontend/vendor/*
 django-admin.py makemessages -l $1 -d djangojs --ignore=frontend/bower_components/* --ignore=frontend/node_modules/* --ignore=frontend/dist/* --ignore=frontend/static/* --ignore=frontend/test/*  --ignore=frontend/vendor/*

+ 1 - 1
misago/frontend/misago/components/misago-markup.js

@@ -5,7 +5,7 @@
     context.retain = true;
     context.retain = true;
   };
   };
 
 
-  Misago.MisagoMarkup = {
+  Misago.Markup = {
     view: function(ctrl, content) {
     view: function(ctrl, content) {
       return m('article.misago-markup', {config: setupMarkup},
       return m('article.misago-markup', {config: setupMarkup},
         m.trust(content)
         m.trust(content)

+ 1 - 1
misago/frontend/misago/routes/legal.js

@@ -44,7 +44,7 @@
         return m('.page.legal-page.' + dashedTypeName + '-page', [
         return m('.page.legal-page.' + dashedTypeName + '-page', [
           _.component(Misago.PageHeader, {title: this.vm.title}),
           _.component(Misago.PageHeader, {title: this.vm.title}),
           m('.container',
           m('.container',
-            _.component(MisagoMarkup. Misago.this.vm.body)
+            _.component(Misago.Markup, Misago.this.vm.body)
           )
           )
         ]);
         ]);
       }
       }

+ 13 - 5
misago/frontend/misago/services/runloop.js

@@ -6,8 +6,16 @@
 
 
     this._intervals = {};
     this._intervals = {};
 
 
+    var stopInterval = function(name) {
+      if (self._intervals[name]) {
+        window.clearTimeout(self._intervals[name]);
+        self._intervals[name] = null;
+      }
+    };
+
     this.run = function(callable, name, delay) {
     this.run = function(callable, name, delay) {
       this._intervals[name] = window.setTimeout(function() {
       this._intervals[name] = window.setTimeout(function() {
+        stopInterval(name);
         var result = callable(_);
         var result = callable(_);
         if (result !== false) {
         if (result !== false) {
           self.run(callable, name, delay);
           self.run(callable, name, delay);
@@ -17,15 +25,15 @@
 
 
     this.runOnce = function(callable, name, delay) {
     this.runOnce = function(callable, name, delay) {
       this._intervals[name] = window.setTimeout(function() {
       this._intervals[name] = window.setTimeout(function() {
+        stopInterval(name);
         callable(_);
         callable(_);
       }, delay);
       }, delay);
     };
     };
 
 
-    this.stop = function() {
-      for (var name in this._intervals) {
-        if (this._intervals.hasOwnProperty(name)) {
-          window.clearTimeout(this._intervals[name]);
-          delete this._intervals[name];
+    this.stop = function(name) {
+      for (var loop in this._intervals) {
+        if (!name || name === loop) {
+          stopInterval(loop);
         }
         }
       }
       }
     };
     };

+ 5 - 5
misago/frontend/misago/utils/serializers.js

@@ -1,9 +1,9 @@
 (function (Misago) {
 (function (Misago) {
-  Misago.deserializeDatetime = function(deserialized) {
-    return deserialized ? moment(deserialized) : null;
-  };
-
   Misago.serializeDatetime = function(serialized) {
   Misago.serializeDatetime = function(serialized) {
     return serialized ? serialized.format() : null;
     return serialized ? serialized.format() : null;
   };
   };
-} (Misago.prototype));
+
+  Misago.deserializeDatetime = function(deserialized) {
+    return deserialized ? moment(deserialized) : null;
+  };
+}(Misago.prototype));

+ 1 - 1
misago/frontend/misago/utils/urlconf.js

@@ -50,4 +50,4 @@
       }
       }
     };
     };
   };
   };
-} (Misago.prototype));
+}(Misago.prototype));

+ 1 - 1
misago/frontend/misago/utils/views-shortcuts.js

@@ -6,4 +6,4 @@
       _.component(Misago.Loader)
       _.component(Misago.Loader)
     );
     );
   };
   };
-} (Misago.prototype));
+}(Misago.prototype));

+ 2 - 2
misago/frontend/test/tests/unit/accessors.js

@@ -37,9 +37,9 @@
     assert.equal(Misago.pop(testObj, 'other_valid', 'fallback'), 'okay',
     assert.equal(Misago.pop(testObj, 'other_valid', 'fallback'), 'okay',
       "Misago.pop() returned value for existing key instead of fallback");
       "Misago.pop() returned value for existing key instead of fallback");
 
 
-    assert.equal(Misago.has(testObj, 'valid'), false,
+    assert.equal(Misago.get(testObj, 'valid'), null,
       "Misago.pop() removed valid key from object");
       "Misago.pop() removed valid key from object");
-    assert.equal(Misago.has(testObj, 'other_valid'), false,
+    assert.equal(Misago.get(testObj, 'other_valid'), null,
       "Misago.pop() removed other valid key from object");
       "Misago.pop() removed other valid key from object");
   });
   });
 }(Misago.prototype));
 }(Misago.prototype));