Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

Commit 49136b9

Browse files
committed
Moved promisify to utils
1 parent 381115f commit 49136b9

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

test/backends/mongoose_test.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@ var should = require('should'),
77
sinon = require('sinon'),
88
mockery = require('mockery');
99

10-
mongoose.connect('mongodb://localhost/test');
11-
12-
Function.prototype.promisify = function(ctx) {
13-
var args = Array.prototype.slice.call(arguments, 1);
10+
require('../utils/promise');
1411

15-
var fn = Promise.denodeify(this);
16-
return fn.apply(ctx, args);
17-
};
12+
mongoose.connect('mongodb://localhost/test');
1813

1914
var userSchema = new Schema({
2015
name: String,
@@ -332,7 +327,7 @@ describe('Backend', function () {
332327
tweet2.createActivity()
333328
];
334329

335-
return backend.enrichActivities(activities)
330+
return backend.enrichActivities(activities);
336331
})
337332
.then(function (enriched) {
338333
enriched.should.length(2);

test/utils/promise.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var Promise = require('promise');
2+
3+
/**
4+
* Use this monkey patch to enable promises on
5+
* mongoose methods
6+
*/
7+
Function.prototype.promisify = function(ctx) {
8+
var args = Array.prototype.slice.call(arguments, 1);
9+
10+
var fn = Promise.denodeify(this);
11+
return fn.apply(ctx, args);
12+
};

0 commit comments

Comments
 (0)