Permalink
Browse files

Merge pull request #15 from Unroll-Me/q-io

Use new q-io library
  • Loading branch information...
2 parents 3d55aa5 + f131056 commit 720e9246826159b8cffd91fc5b44ea9afa396c20 sp committed Nov 26, 2012
Showing with 21 additions and 33 deletions.
  1. +2 −2 lib/FileResponse.js
  2. +1 −1 lib/ViewRegistry.js
  3. +1 −1 lib/stages/Dispatcher.js
  4. +1 −1 lib/stages/FileServer.js
  5. +1 −1 package.json
  6. +15 −27 testing/tests/FileResponseTest.js
View
@@ -29,7 +29,7 @@
var Response = require('./Response').Response;
var pathUtils = require('path');
var fs = require('fs');
-var qfs = require('q-fs');
+var qfs = require('q-io/fs');
var Q = require('q');
var util = require('util');
@@ -83,7 +83,7 @@ var FileResponse = Response.extend(
function(stats) {
if (stats.isFile()) {
r.setHeader('Content-Length', stats.size);
- r.enableCaching(stats.mtime);
+ r.enableCaching(stats.lastModified());
return r;
}
else {
View
@@ -29,7 +29,7 @@
var Class = require('capsela-util').Class
var Logger = require('capsela-util').Logger;
var Log = require('capsela-util').Log;
-var fs = require('q-fs');
+var fs = require('q-io/fs');
var Q = require('q');
var pathUtils = require('path');
View
@@ -32,7 +32,7 @@
var Log = require('capsela-util').Log;
var capsela = require('../../');
-var fs = require('q-fs');
+var fs = require('q-io/fs');
var Q = require('q');
var Dispatcher = capsela.Stage.extend({
View
@@ -29,7 +29,7 @@
var pathUtils = require('path');
var capsela = require('../../');
var Stage = capsela.Stage;
-var qfs = require('q-fs');
+var qfs = require('q-io/fs');
var Q = require('q');
var FileServer = Stage.extend({
View
@@ -15,7 +15,7 @@
"dependencies": {
"capsela-util": ">=0.1.0",
"q": "~0.8",
- "q-fs": ">=0.1.19",
+ "q-io": ">=1.1.0",
"formidable": ">=1.0.5",
"jsdom": ">=0.2.0"
},
@@ -30,12 +30,23 @@ var testbench = require(__dirname + '/../TestBench');
var MonkeyPatcher = require('capsela-util').MonkeyPatcher;
var Pipe = require('capsela-util').Pipe;
var fs = require('fs');
-var qfs = require('q-fs');
+var qfs = require('q-io/fs');
var mp = new MonkeyPatcher();
var Q = require('q');
var FileResponse = require('../../').FileResponse;
+var fileStats = new qfs.Stats({
+ size: 527,
+ mtime: new Date(72000),
+ isFile: function() { return true; }
+});
+var dirStats = new qfs.Stats({
+ size: 527,
+ mtime: new Date(72000),
+ isFile: function() { return false; }
+});
+
module.exports["basics"] = {
tearDown: function(cb) {
@@ -45,17 +56,10 @@ module.exports["basics"] = {
"test create non-file": function(test) {
- var stats = {
- size: 527,
- mtime: new Date(72000),
- isFile: function() {
- return false;
- }
- };
mp.patch(qfs, 'stat', function(path) {
test.equal(path, '/images/sunrise.jpg');
- return Q.resolve(stats);
+ return Q.resolve(dirStats);
});
FileResponse.create('/images/sunrise.jpg').then(null,
@@ -68,17 +72,9 @@ module.exports["basics"] = {
"test create success": function(test) {
- var stats = {
- size: 527,
- mtime: new Date(72000),
- isFile: function() {
- return true;
- }
- };
-
mp.patch(qfs, 'stat', function(path) {
test.equal(path, '/images/sunrise.jpg');
- return Q.resolve(stats);
+ return Q.resolve(fileStats);
});
FileResponse.create('/images/sunrise.jpg').then(
@@ -97,17 +93,9 @@ module.exports["basics"] = {
var pipe = new Pipe();
var bodyBuffer = new Pipe(true);
- var stats = {
- size: 527,
- mtime: new Date(72000),
- isFile: function() {
- return true;
- }
- };
-
mp.patch(qfs, 'stat', function(path) {
test.equal(path, '/images/sunrise.jpg');
- return Q.resolve(stats);
+ return Q.resolve(fileStats);
});
mp.patch(fs, 'createReadStream', function(path) {

0 comments on commit 720e924

Please sign in to comment.