Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updates to reflect changes in Q.

  • Loading branch information...
commit de3a371479023e6501fac765feeac003c21acf00 1 parent fde719f
Seth Purcell authored
Showing with 79 additions and 71 deletions.
  1. +4 −4 lib/Server.js
  2. +4 −4 lib/SessionStore.js
  3. +5 −1 lib/stages/ErrorHandler.js
  4. +1 −1  lib/stages/SessionManager.js
  5. +1 −1  lib/stages/ViewRenderer.js
  6. +1 −1  testing/rigs/HttpClientRig.js
  7. +1 −1  testing/rigs/UnitBrowser.js
  8. +1 −1  testing/tests/BlobResponseTest.js
  9. +6 −5 testing/tests/BrowserTest.js
  10. +1 −1  testing/tests/CookieTest.js
  11. +4 −4 testing/tests/FileResponseTest.js
  12. +1 −1  testing/tests/FormTest.js
  13. +5 −4 testing/tests/HttpClientTest.js
  14. +1 −1  testing/tests/JsonResponseTest.js
  15. +3 −2 testing/tests/LayoutResponseTest.js
  16. +1 −1  testing/tests/RedirectTest.js
  17. +1 −1  testing/tests/RequestTest.js
  18. +1 −1  testing/tests/ResolverTest.js
  19. +1 −1  testing/tests/ResponseTest.js
  20. +1 −1  testing/tests/RouteTest.js
  21. +4 −4 testing/tests/ServerTest.js
  22. +1 −1  testing/tests/ServiceTest.js
  23. +1 −1  testing/tests/SessionStoreTest.js
  24. +1 −1  testing/tests/SessionTest.js
  25. +1 −1  testing/tests/StageTest.js
  26. +1 −1  testing/tests/ViewRegistryTest.js
  27. +3 −2 testing/tests/ViewResponseTest.js
  28. +1 −1  testing/tests/ViewTest.js
  29. +1 −1  testing/tests/stages/DispatcherTest.js
  30. +2 −2 testing/tests/stages/ErrorHandlerTest.js
  31. +1 −1  testing/tests/stages/FileServerTest.js
  32. +1 −1  testing/tests/stages/PreferredHostTest.js
  33. +1 −1  testing/tests/stages/RouterTest.js
  34. +12 −12 testing/tests/stages/SessionManagerTest.js
  35. +1 −1  testing/tests/stages/ViewRendererTest.js
  36. +1 −1  testing/tests/views/EjsTest.js
  37. +1 −1  testing/tests/views/JsonMLTest.js
  38. +1 −1  testing/tests/views/JsonTemplateTest.js
View
8 lib/Server.js
@@ -161,8 +161,8 @@ var Server = Service.extend(
this.echo(request);
- Q.call(
- function() {
+ Q.fcall(
+ function () {
return t.service(request);
}
).then(
@@ -178,9 +178,9 @@ var Server = Service.extend(
return new capsela.Response(500, {}, "stages produced an invalid response");
},
- function(err) {
+ function (err) {
- // if there was a processing error, return a 500
+ // there was a processing error, return a 500
return new capsela.Response(500, {}, err.message);
}
).then(
View
8 lib/SessionStore.js
@@ -56,7 +56,7 @@ var SessionStore = Class.extend(
* @return promise
*/
load: function(id) {
- return Q.ref(this.sessions[id]);
+ return Q.resolve(this.sessions[id]);
},
////////////////////////////////////////////////////////////////////////////
@@ -71,7 +71,7 @@ var SessionStore = Class.extend(
session.touch();
session.store = this;
this.sessions[session.getId()] = session;
- return Q.ref(session);
+ return Q.resolve(session);
},
////////////////////////////////////////////////////////////////////////////
@@ -84,7 +84,7 @@ var SessionStore = Class.extend(
*/
destroy: function(session) {
delete this.sessions[session.getId()];
- return Q.ref();
+ return Q.resolve();
},
////////////////////////////////////////////////////////////////////////////
@@ -105,7 +105,7 @@ var SessionStore = Class.extend(
}
}
- return Q.ref();
+ return Q.resolve();
}
});
View
6 lib/stages/ErrorHandler.js
@@ -42,7 +42,11 @@ var ErrorHandler = capsela.Stage.extend({
var t = this;
- return Q.call(this.pass, this, request).then(
+ return Q.fcall(
+ function () {
+ return t.pass(request);
+ }
+ ).then(
function(response) {
// turn empty responses into errors
View
2  lib/stages/SessionManager.js
@@ -135,7 +135,7 @@ var SessionManager = Stage.extend({
function createSession() {
var session = new Session();
result.created = true;
- return Q.ref(session);
+ return Q.resolve(session);
};
if (sid) {
View
2  lib/stages/ViewRenderer.js
@@ -55,7 +55,7 @@ var ViewRenderer = capsela.Stage.extend({
this.ready = this.vr.loadViews(dir, type);
}
else {
- this.ready = Q.ref();
+ this.ready = Q.resolve();
}
},
View
2  testing/rigs/HttpClientRig.js
@@ -33,7 +33,7 @@ var http = require('http');
var https = require('https');
var Pipe = require('capsela-util').Pipe;
var Class = require('capsela-util').Class;
-var Server = require('capsela').Server;
+var Server = require('../../').Server;
var orig = {
httpRequest: http.request,
View
2  testing/rigs/UnitBrowser.js
@@ -29,7 +29,7 @@
var fs = require('fs');
var path = require('path');
-var capsela = require('capsela');
+var capsela = require('../../');
var Browser = capsela.Browser;
var HttpClient = capsela.HttpClient;
var Request = capsela.Request;
View
2  testing/tests/BlobResponseTest.js
@@ -29,7 +29,7 @@
var testbench = require(__dirname + '/../TestBench');
var Pipe = require('capsela-util').Pipe;
-var BlobResponse = require('capsela').BlobResponse;
+var BlobResponse = require('../../').BlobResponse;
module.exports["basics"] = {
View
11 testing/tests/BrowserTest.js
@@ -28,11 +28,12 @@
var testbench = require(__dirname + '/../TestBench');
-var Browser = require('capsela').Browser;
-var Request = require('capsela').Request;
-var Response = require('capsela').Response;
-var HttpClientRig = require('capsela').rigs.HttpClientRig;
-var Stage = require('capsela').Stage;
+var capsela = require('../../');
+var Browser = capsela.Browser;
+var Request = capsela.Request;
+var Response = capsela.Response;
+var HttpClientRig = capsela.rigs.HttpClientRig;
+var Stage = capsela.Stage;
module.exports["basics"] = {
View
2  testing/tests/CookieTest.js
@@ -28,7 +28,7 @@
var testbench = require(__dirname + '/../TestBench');
-var Cookie = require('capsela').Cookie;
+var Cookie = require('../../').Cookie;
module.exports["parsing"] = {
View
8 testing/tests/FileResponseTest.js
@@ -34,7 +34,7 @@ var qfs = require('q-fs');
var mp = new MonkeyPatcher();
var Q = require('q');
-var FileResponse = require('capsela').FileResponse;
+var FileResponse = require('../../').FileResponse;
module.exports["basics"] = {
@@ -55,7 +55,7 @@ module.exports["basics"] = {
mp.patch(qfs, 'stat', function(path) {
test.equal(path, '/images/sunrise.jpg');
- return Q.ref(stats);
+ return Q.resolve(stats);
});
FileResponse.create('/images/sunrise.jpg').then(null,
@@ -78,7 +78,7 @@ module.exports["basics"] = {
mp.patch(qfs, 'stat', function(path) {
test.equal(path, '/images/sunrise.jpg');
- return Q.ref(stats);
+ return Q.resolve(stats);
});
FileResponse.create('/images/sunrise.jpg').then(
@@ -107,7 +107,7 @@ module.exports["basics"] = {
mp.patch(qfs, 'stat', function(path) {
test.equal(path, '/images/sunrise.jpg');
- return Q.ref(stats);
+ return Q.resolve(stats);
});
mp.patch(fs, 'createReadStream', function(path) {
View
2  testing/tests/FormTest.js
@@ -28,7 +28,7 @@
var testbench = require(__dirname + '/../TestBench');
-var capsela = require('capsela');
+var capsela = require('../../');
var Form = capsela.Form;
var Pipe = require('capsela-util').Pipe;
var Request = capsela.Request;
View
9 testing/tests/HttpClientTest.js
@@ -28,10 +28,11 @@
var TestBench = require('../TestBench');
-var Request = require('capsela').Request;
+var capsela = require('../../');
+var Request = capsela.Request;
-var HttpClient = require('capsela').HttpClient;
-var Response = require('capsela').Response;
+var HttpClient = capsela.HttpClient;
+var Response = capsela.Response;
var http = require('http');
var https = require('https');
@@ -353,7 +354,7 @@ module.exports["basics"] = {
request.bodyStream = {
end: function() {}
};
- return Q.ref(mockResponse);
+ return Q.resolve(mockResponse);
}
}
};
View
2  testing/tests/JsonResponseTest.js
@@ -28,7 +28,7 @@
var testbench = require(__dirname + '/../TestBench');
-var JsonResponse = require('capsela').JsonResponse;
+var JsonResponse = require('../../').JsonResponse;
var Pipe = require('capsela-util').Pipe;
module.exports["basics"] = {
View
5 testing/tests/LayoutResponseTest.js
@@ -31,8 +31,9 @@ var MonkeyPatcher = require('capsela-util').MonkeyPatcher;
var Pipe = require('capsela-util').Pipe;
var mp = new MonkeyPatcher();
-var View = require('capsela').View;
-var LayoutResponse = require('capsela').LayoutResponse;
+var capsela = require('../../');
+var View = capsela.View;
+var LayoutResponse = capsela.LayoutResponse;
module.exports["basics"] = {
View
2  testing/tests/RedirectTest.js
@@ -28,7 +28,7 @@
var testbench = require(__dirname + '/../TestBench');
-var Redirect = require('capsela').Redirect;
+var Redirect = require('../../').Redirect;
module.exports["basics"] = {
View
2  testing/tests/RequestTest.js
@@ -31,7 +31,7 @@ var querystring = require('querystring');
var Pipe = require('capsela-util').Pipe;
var fs = require('fs');
-var capsela = require('capsela');
+var capsela = require('../../');
var Request = capsela.Request;
var Form = capsela.Form;
var Log = require('capsela-util').Log;
View
2  testing/tests/ResolverTest.js
@@ -28,7 +28,7 @@
var testbench = require(__dirname + '/../TestBench');
-var capsela = require('capsela');
+var capsela = require('../../');
module.exports["basics"] = {
View
2  testing/tests/ResponseTest.js
@@ -30,7 +30,7 @@ var testbench = require('../TestBench');
var fs = require('fs');
-var Response = require('capsela').Response;
+var Response = require('../../').Response;
var Pipe = require('capsela-util').Pipe;
module.exports["headers"] = {
View
2  testing/tests/RouteTest.js
@@ -28,7 +28,7 @@
var testbench = require('../TestBench');
-var Route = require('capsela').Route;
+var Route = require('../../').Route;
var controller = {
View
8 testing/tests/ServerTest.js
@@ -34,7 +34,7 @@ var fs = require('fs');
var path = require('path');
var StreamUtil = require('capsela-util').StreamUtil;
-var capsela = require('capsela');
+var capsela = require('../../');
var Server = capsela.Server;
var Response = capsela.Response;
var Form = capsela.Form;
@@ -42,7 +42,7 @@ var Request = capsela.Request;
var Log = require('capsela-util').Log;
var Q = require('q');
-var mocks = require('capsela').mocks;
+var mocks = capsela.mocks;
var MonkeyPatcher = require('capsela-util').MonkeyPatcher;
@@ -310,7 +310,7 @@ module.exports["construct/start"] = {
server.isReady = function() {
test.ok(true);
- return Q.ref();
+ return Q.resolve();
};
server.start().then(function() {
@@ -706,7 +706,7 @@ module.exports["request processing"] = {
server.addStage(
function(request) {
- return Q.ref().then(
+ return Q.resolve().then(
function() {
throw new Error("fool! you've killed us all!");
});
View
2  testing/tests/ServiceTest.js
@@ -26,7 +26,7 @@
"use strict";
-var capsela = require('capsela');
+var capsela = require('../../');
var Service = capsela.Service;
var mp = require('capsela-util').MonkeyPatcher;
var Log = require('capsela-util').Log;
View
2  testing/tests/SessionStoreTest.js
@@ -28,7 +28,7 @@
var testbench = require('../TestBench');
-var capsela = require('capsela');
+var capsela = require('../../');
var Session = capsela.Session;
var SessionStore = capsela.SessionStore;
View
2  testing/tests/SessionTest.js
@@ -28,7 +28,7 @@
var testbench = require('../TestBench');
-var capsela = require('capsela');
+var capsela = require('../../');
var Session = capsela.Session;
var crypto = require('crypto');
View
2  testing/tests/StageTest.js
@@ -28,7 +28,7 @@
var testbench = require(__dirname + '/../TestBench');
-var capsela = require('capsela');
+var capsela = require('../../');
var Stage = capsela.Stage;
var Q = require('q');
View
2  testing/tests/ViewRegistryTest.js
@@ -26,7 +26,7 @@
"use strict";
-var capsela = require('capsela');
+var capsela = require('../../');
var ViewRegistry = capsela.ViewRegistry;
var JsonTemplate = capsela.views.JsonTemplate;
View
5 testing/tests/ViewResponseTest.js
@@ -31,8 +31,9 @@ var MonkeyPatcher = require('capsela-util').MonkeyPatcher;
var Pipe = require('capsela-util').Pipe;
var mp = new MonkeyPatcher();
-var View = require('capsela').View;
-var ViewResponse = require('capsela').ViewResponse;
+var capsela = require('../../')
+var View = capsela.View;
+var ViewResponse = capsela.ViewResponse;
module.exports["basics"] = {
View
2  testing/tests/ViewTest.js
@@ -28,7 +28,7 @@
var testbench = require(__dirname + '/../TestBench');
-var capsela = require('capsela');
+var capsela = require('../../');
var View = capsela.View;
module.exports["basics"] = {
View
2  testing/tests/stages/DispatcherTest.js
@@ -10,7 +10,7 @@
var testbench = require(__dirname + '/../../TestBench');
-var capsela = require('capsela');
+var capsela = require('../../../');
var Dispatcher = capsela.stages.Dispatcher;
var View = capsela.View;
View
4 testing/tests/stages/ErrorHandlerTest.js
@@ -30,7 +30,7 @@ var testbench = require('../../TestBench');
var fs = require('fs');
-var capsela = require('capsela');
+var capsela = require('../../../');
var Response = capsela.Response;
var Request = capsela.Request;
var Stage = capsela.Stage;
@@ -78,7 +78,7 @@ module.exports = {
handler.setNext(
function(request) {
- return Q.ref();
+ return Q.resolve();
});
Q.when(handler.service(request),
View
2  testing/tests/stages/FileServerTest.js
@@ -30,7 +30,7 @@ var testbench = require('../../TestBench');
var fs = require('fs');
-var capsela = require('capsela');
+var capsela = require('../../../');
var Response = capsela.Response;
var Request = capsela.Request;
var FileServer = capsela.stages.FileServer;
View
2  testing/tests/stages/PreferredHostTest.js
@@ -28,7 +28,7 @@
var testbench = require(__dirname + '/../../TestBench');
-var capsela = require('capsela');
+var capsela = require('../../../');
var PreferredHost = capsela.stages.PreferredHost;
var View = capsela.View;
View
2  testing/tests/stages/RouterTest.js
@@ -28,7 +28,7 @@
var testbench = require('../../TestBench');
-var capsela = require('capsela');
+var capsela = require('../../../');
var Response = capsela.Response;
var Request = capsela.Request;
var Router = capsela.stages.Router;
View
24 testing/tests/stages/SessionManagerTest.js
@@ -29,7 +29,7 @@
var testbench = require('../../TestBench');
-var capsela = require('capsela');
+var capsela = require('../../../');
var SessionManager = capsela.stages.SessionManager;
var SessionStore = capsela.SessionStore;
var Session = capsela.Session;
@@ -111,7 +111,7 @@ module.exports["establishing"] = {
load: function(id) {
test.equal(id, 'the-xx');
- return Q.ref(mockSession);
+ return Q.resolve(mockSession);
}
};
@@ -141,7 +141,7 @@ module.exports["establishing"] = {
load: function(id) {
test.equal(id, 'the-xx');
- return Q.ref(mockSession);
+ return Q.resolve(mockSession);
}
};
@@ -170,11 +170,11 @@ module.exports["servicing"] = {
save: function(saved) {
test.equal(saved, session);
- return Q.ref();
+ return Q.resolve();
},
load: function(sid) {
- return Q.ref(session);
+ return Q.resolve(session);
}
};
@@ -211,12 +211,12 @@ module.exports["servicing"] = {
save: function(saved) {
test.equal(saved, session);
- return Q.ref();
+ return Q.resolve();
},
load: function(sid) {
test.equal(sid, session.getId());
- return Q.ref(session);
+ return Q.resolve(session);
}
};
@@ -251,16 +251,16 @@ module.exports["servicing"] = {
save: function(saved) {
test.equal(saved, session);
- return Q.ref();
+ return Q.resolve();
},
load: function(sid) {
- return Q.ref(session);
+ return Q.resolve(session);
},
destroy: function(destroyed) {
test.equal(destroyed, session);
- return Q.ref();
+ return Q.resolve();
}
};
@@ -296,7 +296,7 @@ module.exports["servicing"] = {
var response = new Response();
sm.pass = function(request) {
- return Q.ref(response);
+ return Q.resolve(response);
};
response.setHeader = function(name, value) {
@@ -317,7 +317,7 @@ module.exports["servicing"] = {
var response = new Response();
sm.pass = function(request) {
- return Q.ref();
+ return Q.resolve();
};
var request = new Request();
View
2  testing/tests/stages/ViewRendererTest.js
@@ -30,7 +30,7 @@ var testbench = require('../../TestBench');
var fs = require('fs');
-var capsela = require('capsela');
+var capsela = require('../../../');
var Response = capsela.Response;
var Request = capsela.Request;
var Stage = capsela.Stage;
View
2  testing/tests/views/EjsTest.js
@@ -26,7 +26,7 @@
"use strict";
-var Ejs = require('capsela').views.Ejs;
+var Ejs = require('../../../').views.Ejs;
module.exports["basics"] = {
View
2  testing/tests/views/JsonMLTest.js
@@ -28,7 +28,7 @@
var testbench = require(__dirname + '/../../TestBench');
-var capsela = require('capsela');
+var capsela = require('../../../');
var JsonML = capsela.views.JsonML;
var mp = require('capsela-util').MonkeyPatcher;
View
2  testing/tests/views/JsonTemplateTest.js
@@ -28,7 +28,7 @@
var testbench = require(__dirname + '/../../TestBench');
-var capsela = require('capsela');
+var capsela = require('../../../');
var JsonTemplate = capsela.views.JsonTemplate;
var mp = require('capsela-util').MonkeyPatcher;
Please sign in to comment.
Something went wrong with that request. Please try again.