Skip to content

Commit 58cb5cc

Browse files
authored
Merge branch 'master' into greenkeeper-request-2.80.0
2 parents 01fc0e4 + d3df3fe commit 58cb5cc

File tree

9 files changed

+146
-172
lines changed

9 files changed

+146
-172
lines changed

config/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ module.exports = {
3535
workflows: {
3636
directory: path.join(__dirname, '../tests/fixtures/workflows/good'),
3737
},
38+
storage: {
39+
dest: 'tests/public/files',
40+
temp: {
41+
dest: 'tests/public/tmp/',
42+
},
43+
},
3844
};

lib/users/routes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ const setup = (req, res, next) => {
6565
* @param {object} res - HTTP Response
6666
* @param {object} next - Express callback
6767
*
68+
* @returns {promise} database promise
69+
*
6870
*/
6971
const all = (req, res, next) => {
70-
database.select('*').from('users').then(rows => {
72+
return database.select('*').from('users').then(rows => {
7173
res.render('users/all', {
7274
title: config.users.base,
7375
users: rows,

package.json

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@
4646
"dependencies": {
4747
"acl": "^0.4.9",
4848
"bcrypt-nodejs": "0.0.3",
49-
"body-parser": "^1.15.2",
49+
"body-parser": "^1.17.2",
5050
"breakpoint-sass": "^2.7.1",
5151
"cfenv": "^1.0.3",
52-
"config": "^1.20.4",
52+
"config": "^1.26.1",
5353
"connect-ensure-login": "^0.1.1",
5454
"connect-multiparty": "^2.0.0",
5555
"connect-session-knex": "^1.0.23",
56-
"debug": "^2.4.5",
57-
"express": "^4.14.0",
58-
"express-session": "^1.13.0",
59-
"ibm-design-colors": "^1.8.0",
56+
"debug": "^2.6.8",
57+
"express": "^4.15.3",
58+
"express-session": "^1.15.3",
59+
"ibm-design-colors": "^2.0.4",
6060
"input-plugin-checkbox": "^0.3.1",
6161
"input-plugin-email": "^0.2.0",
6262
"input-plugin-file": "^1.2.1",
@@ -67,55 +67,56 @@
6767
"input-plugin-text": "^0.1.3",
6868
"input-plugin-textarea": "^0.1.3",
6969
"input-plugin-url": "^0.3.0",
70-
"js-yaml": "^3.6.1",
71-
"knex": "^0.12.6",
70+
"js-yaml": "^3.8.4",
71+
"knex": "^0.13.0",
7272
"lodash": "^4.17.2",
73-
"map-stream": "^0.0.6",
73+
"map-stream": "^0.0.7",
7474
"mkdirp": "^0.5.1",
75-
"modularscale-sass": "^2.1.1",
76-
"moment": "^2.15.0",
77-
"moment-timezone": "^0.5.4",
78-
"morgan": "^1.6.1",
75+
"modularscale-sass": "^3.0.2",
76+
"moment": "^2.18.1",
77+
"moment-timezone": "^0.5.13",
78+
"morgan": "^1.8.2",
7979
"multer": "^1.2.1",
8080
"multiparty": "^4.1.2",
81-
"node-dir": "^0.1.11",
82-
"node-schedule": "^1.1.1",
81+
"node-dir": "^0.1.17",
82+
"node-schedule": "^1.2.3",
8383
"nodemon": "^1.10.0",
84-
"nunjucks": "^3.0.0",
84+
"nunjucks": "^3.0.1",
8585
"passport": "^0.3.2",
8686
"passport-local": "^1.0.0",
87-
"pg": "^6.0.1",
87+
"pg": "^6.2.3",
8888
"punchcard-content-types": "^6.1.15",
8989
"request": "^2.80.0",
9090
"sass-toolkit": "^2.10.0",
91-
"serve-favicon": "^2.3.0",
91+
"serve-favicon": "^2.4.3",
9292
"stream-from-array": "^1.0.0",
9393
"underscore.string": "^3.3.4",
94-
"url-join": "^1.1.0",
94+
"url-join": "^2.0.2",
9595
"uuid": "^2.0.2",
9696
"validator": "^6.0.0",
9797
"vinyl": "^2.0.0",
9898
"vinyl-fs": "^2.4.4"
9999
},
100100
"devDependencies": {
101-
"ava": "^0.16.0",
102-
"coveralls": "^2.11.9",
101+
"ava": "^0.19.1",
102+
"ava-config": "^1.1.0",
103+
"coveralls": "^2.13.1",
103104
"del": "^2.2.2",
104105
"eslint-config-punchcard": "^1.1.1",
105106
"ghooks": "^2.0.0",
106107
"gulp": "^3.9.1",
107108
"input-plugin-file": "^1.1.0",
108-
"lorem-ipsum": "^1.0.3",
109+
"lorem-ipsum": "^1.0.4",
109110
"mock-express-response": "^0.1.2",
110-
"nock": "^9.0.0",
111-
"node-mocks-http": "^1.5.3",
112-
"nyc": "^10.0.0",
111+
"nock": "^9.0.12",
112+
"node-mocks-http": "^1.6.3",
113+
"nyc": "^10.3.2",
113114
"punchcard-commit-msg": "^1.0.0",
114115
"punchcard-runner": "^2.1.2",
115116
"punchcard-semantic-release": "^2.0.3",
116117
"punchcard-shared-tests": "^1.3.0",
117118
"reparo": "^1.1.1-0",
118-
"semantic-release": "^6.3.2",
119+
"semantic-release": "^6.3.6",
119120
"supertest": "^2.0.1",
120121
"tap-difflet": "^0.7.0",
121122
"uuid": "^2.0.2"
@@ -139,7 +140,10 @@
139140
"!tests/schedule.js"
140141
],
141142
"failFast": false,
142-
"tap": false
143+
"tap": false,
144+
"require": [
145+
"ava-config"
146+
]
143147
},
144148
"config": {
145149
"ghooks": {

src/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(function app() {
22
'use strict';
33

4-
console.log('Hello World');
4+
console.log('Hello World'); // eslint-disable-line no-console
55
}());

tests/applications.js

Lines changed: 33 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -356,60 +356,53 @@ test('Send - bad urls', t => {
356356
//////////////////////////////
357357
// Routes - Applications landing
358358
//////////////////////////////
359-
test.cb('All applications route', t => {
359+
test('All applications route', t => {
360360
const request = httpMocks.createRequest(reqObj);
361361

362362
const response = httpMocks.createResponse({ eventEmitter: EventEmitter });
363363
applications.routes.all(request, response);
364364
response.render();
365+
const data = response._getRenderData();
366+
const app = data.applications.find((ap) => {
367+
return ap.name === 'Foo First Application';
368+
});
365369

366-
response.on('end', () => {
367-
const data = response._getRenderData();
368-
const app = data.applications.find((ap) => {
369-
return ap.name === 'Foo First Application';
370-
});
371-
372-
t.is(response.statusCode, 200, 'Should be a 200 response');
373-
t.is(app.name, 'Foo First Application', 'includes form with inputs');
374-
375-
t.is(_.get(app, 'responses.live[0].response', null), 200, 'includes live response');
376-
t.true(_.isDate(new Date(_.get(app, 'responses.live[0].timestamp', null))), 'includes live timestamp which is a date');
377-
t.is(_.get(app, 'responses.updated[0].response', null), 200, 'includes updated response');
378-
t.true(_.isDate(new Date(_.get(app, 'responses.updated[0].timestamp', null))), 'includes updated timestamp which is a date');
379-
t.is(_.get(app, 'responses.sunset[0].response', null), 200, 'includes sunset response');
380-
t.true(_.isDate(new Date(_.get(app, 'responses.sunset[0].timestamp', null))), 'includes sunset timestamp which is a date');
370+
t.is(response.statusCode, 200, 'Should be a 200 response');
371+
t.is(app.name, 'Foo First Application', 'includes form with inputs');
381372

382-
t.end();
383-
});
384-
response.end();
373+
t.is(_.get(app, 'responses.live[0].response', null), 200, 'includes live response');
374+
t.true(_.isDate(new Date(_.get(app, 'responses.live[0].timestamp', null))), 'includes live timestamp which is a date');
375+
t.is(_.get(app, 'responses.updated[0].response', null), 200, 'includes updated response');
376+
t.true(_.isDate(new Date(_.get(app, 'responses.updated[0].timestamp', null))), 'includes updated timestamp which is a date');
377+
t.is(_.get(app, 'responses.sunset[0].response', null), 200, 'includes sunset response');
378+
t.true(_.isDate(new Date(_.get(app, 'responses.sunset[0].timestamp', null))), 'includes sunset timestamp which is a date');
385379
});
386380

387381
//////////////////////////////
388382
// Routes - New Application
389383
//////////////////////////////
390-
test.cb('New application route', t => {
384+
test('New application route', t => {
391385
const req = _.cloneDeep(reqObj);
392386
req.url = '/applications/add';
393387

394388
const request = httpMocks.createRequest(req);
395389

396390
const response = httpMocks.createResponse({ eventEmitter: EventEmitter });
397-
applications.routes.add(request, response);
391+
const resp = applications.routes.add(request, response);
398392
response.render();
399393

400-
response.on('end', () => {
394+
return resp.then(() => {
401395
const data = response._getRenderData();
402396

403397
t.is(response.statusCode, 200, 'Should be a 200 response');
404398
t.true(_.includes(data.form.html, 'name="sunset-endpoint--url"'), 'includes form with inputs');
405-
t.end();
406399
});
407400
});
408401

409402
//////////////////////////////
410403
// Routes - Single application
411404
//////////////////////////////
412-
test.cb('Single application route', t => {
405+
test('Single application route', t => {
413406
const req = _.cloneDeep(reqObj);
414407
req.url = '/applications/1';
415408
req.params.id = 1;
@@ -420,7 +413,7 @@ test.cb('Single application route', t => {
420413
const resp = applications.routes.one(request, response);
421414
response.render();
422415

423-
response.on('end', () => {
416+
return resp.then(() => {
424417
const data = response._getRenderData();
425418

426419
t.is(response.statusCode, 200, 'Should be a 200 response');
@@ -435,11 +428,6 @@ test.cb('Single application route', t => {
435428
t.is(data.config.toString(), config.applications.toString(), 'includes config for applications');
436429
t.is(data.app.name, 'Foo First Application', 'includes data from database');
437430
t.is(data.button, 'update', 'includes `update` as text for button');
438-
439-
return resp.then(res => {
440-
t.is(res, true, 'should return true');
441-
t.end();
442-
});
443431
});
444432
});
445433

@@ -464,7 +452,7 @@ test.cb('Single application route - bad id', t => {
464452
response.render();
465453
});
466454

467-
test.cb('Single application route - error on save', t => {
455+
test('Single application route - error on save', t => {
468456
const req = _.cloneDeep(reqObj);
469457
req.url = '/applications/3';
470458
req.params.id = 3;
@@ -482,25 +470,23 @@ test.cb('Single application route - error on save', t => {
482470
const request = httpMocks.createRequest(req);
483471

484472
const response = httpMocks.createResponse({ eventEmitter: EventEmitter });
485-
applications.routes.one(request, response);
473+
const resp = applications.routes.one(request, response);
486474
response.render();
487475

488-
response.on('end', () => {
476+
return resp.then(() => {
489477
const data = response._getRenderData();
490478

491479
t.is(response.statusCode, 200, 'Should be a 200 response');
492480

493481
// form shows error
494482
t.regex(data.form.html, /<p class="form--alert" role="alert" for="([0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})">Field is required to be saved!<\/p>/g, 'includes form alert');
495-
496-
t.end();
497483
});
498484
});
499485

500486
//////////////////////////////
501487
// Routes - Secret
502488
//////////////////////////////
503-
test.cb('Create new secret', t => {
489+
test('Create new secret', t => {
504490
const req = _.cloneDeep(reqObj);
505491
req.method = 'POST';
506492
req.headers.referrer = '/applications/1';
@@ -512,18 +498,12 @@ test.cb('Create new secret', t => {
512498
const resp = applications.routes.secret(request, response, next);
513499
response.render();
514500

515-
return response.on('end', () => {
516-
t.is(response.statusCode, 302, 'Should be a 302 response');
517-
t.is(response._getRedirectUrl(), '/applications/1', 'should redirect to edit url');
518-
519-
return resp.then(res => {
520-
t.not(res, dbmocks.rows[0]['client-secret'], 'should be a new client secret');
521-
t.end();
522-
});
501+
return resp.then(res => {
502+
t.not(res, dbmocks.rows[0]['client-secret'], 'should be a new client secret');
523503
});
524504
});
525505

526-
test.cb('Create new secret - bad id kills db', t => {
506+
test('Create new secret - bad id kills db', t => {
527507
const req = _.cloneDeep(reqObj);
528508
req.method = 'POST';
529509
req.headers.referrer = '/applications/break';
@@ -534,9 +514,8 @@ test.cb('Create new secret - bad id kills db', t => {
534514
const response = httpMocks.createResponse({ eventEmitter: EventEmitter });
535515
const resp = applications.routes.secret(request, response, next);
536516

537-
resp.then(res => {
517+
return resp.then(res => {
538518
t.true(_.includes(res.message, 'update "applications" set "client-secret"'), 'postgres error');
539-
t.end();
540519
});
541520
});
542521

@@ -565,7 +544,7 @@ test.cb('Create new secret - bad referrer', t => {
565544
//////////////////////////////
566545
// Routes - Save application
567546
//////////////////////////////
568-
test.cb('Save new app: name required', t => {
547+
test('Save new app: name required', t => {
569548
const req = _.cloneDeep(reqObj);
570549
req.method = 'POST';
571550
req.session.referrer = '/applications/add';
@@ -577,16 +556,13 @@ test.cb('Save new app: name required', t => {
577556

578557
const response = httpMocks.createResponse({ eventEmitter: EventEmitter });
579558
applications.routes.save(request, response);
580-
581-
response.on('end', () => {
582-
t.is(response.statusCode, 302, 'Should be a 302 response');
583-
t.is(response._getRedirectUrl(), '/applications/add');
584-
t.end();
585-
});
586559
response.render();
560+
561+
t.is(response.statusCode, 302, 'Should be a 302 response');
562+
t.is(response._getRedirectUrl(), '/applications/add');
587563
});
588564

589-
test.cb('Save existing app: name required', t => {
565+
test('Save existing app: name required', t => {
590566
const req = _.cloneDeep(reqObj);
591567
req.method = 'POST';
592568
req.session.referrer = '/applications/123';
@@ -599,12 +575,8 @@ test.cb('Save existing app: name required', t => {
599575
const response = httpMocks.createResponse({ eventEmitter: EventEmitter });
600576
applications.routes.save(request, response);
601577

602-
response.on('end', () => {
603-
t.is(response.statusCode, 302, 'Should be a 302 response');
604-
t.is(response._getRedirectUrl(), '/applications/123');
605-
t.end();
606-
});
607-
response.render();
578+
t.is(response.statusCode, 302, 'Should be a 302 response');
579+
t.is(response._getRedirectUrl(), '/applications/123');
608580
});
609581

610582
test.cb('Delete existing application', t => {

tests/content-middleware.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ test('Check revision id-not missing', t => {
9999
const rq = cloneDeep(req);
100100
delete rq.params.revision;
101101

102-
return utils.revision(rq).catch(err => {
103-
t.is(typeof err, 'string', 'Non-number revision fails');
104-
t.is(err, 'Revision must be a number', 'Should fail with a message');
102+
return utils.revision(rq).then(resp => {
103+
t.true(resp, 'should be true without a revision number');
104+
}).catch(err => {
105+
t.is(err, null, 'should not have an error');
105106
});
106107
});
107108

0 commit comments

Comments
 (0)