Skip to content

Commit 519f628

Browse files
committed
TEMP
1 parent 4859cc1 commit 519f628

File tree

6 files changed

+54
-32
lines changed

6 files changed

+54
-32
lines changed

Diff for: app/templates/Gruntfile.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ module.exports = function (grunt) {
206206
]
207207
}]
208208
},
209-
server: '.tmp'
209+
server: '.tmp',
210+
coverage_server_unit: 'coverage/server/unit/*',
211+
coverage_server_e2e: 'coverage/server/e2e/*'
210212
},
211213

212214
// Add vendor prefixed styles
@@ -501,6 +503,7 @@ module.exports = function (grunt) {
501503
mocha_istanbul: {
502504
unit: {
503505
options: {
506+
root: 'server',
504507
excludes: [
505508
'**/*.spec.js',
506509
'**/*.mock.js',
@@ -515,6 +518,7 @@ module.exports = function (grunt) {
515518
},
516519
e2e: {
517520
options: {
521+
root: 'server',
518522
excludes: [
519523
'**/*.spec.js',
520524
'**/*.mock.js',
@@ -863,6 +867,7 @@ module.exports = function (grunt) {
863867
return grunt.task.run([
864868
'env:all',
865869
'env:test',
870+
'clean:coverage_server_unit',
866871
'mocha_istanbul:unit'
867872
]);
868873
}
@@ -871,6 +876,7 @@ module.exports = function (grunt) {
871876
return grunt.task.run([
872877
'env:all',
873878
'env:test',
879+
'clean:coverage_server_e2e',
874880
'mocha_istanbul:e2e'
875881
]);
876882
}
@@ -885,6 +891,8 @@ module.exports = function (grunt) {
885891
return grunt.task.run([
886892
'env:all',
887893
'env:test',
894+
'clean:coverage_server_unit',
895+
'clean:coverage_server_e2e',
888896
'mocha_istanbul',
889897
'istanbul_check_coverage'
890898
]);

Diff for: app/templates/server/.jshintrc-spec

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"extends": ".jshintrc",
3+
"expr": true,
34
"globals": {
45
"describe": true,
56
"it": true,

Diff for: app/templates/server/api/thing/index.spec.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var proxyquire = require('proxyquire').noPreserveCache();
3+
var proxyquire = require('proxyquire').noPreserveCache().noCallThru();
44

55
/* thing.controller stub */
66
var thingCtrl = {
@@ -37,47 +37,47 @@ describe('Thing API Router:', function() {
3737
describe('GET /api/things', function() {
3838

3939
it('should route to thing.controller.index', function() {
40-
return router.get.withArgs('/', 'thingCtrl.index').should.have.been.calledOnce;
40+
router.get.withArgs('/', 'thingCtrl.index').should.have.been.calledOnce;
4141
});
4242

4343
});<% if(filters.mongoose) { %>
4444

4545
describe('GET /api/things/:id', function() {
4646

4747
it('should route to thing.controller.show', function() {
48-
return router.get.withArgs('/:id', 'thingCtrl.show').should.have.been.calledOnce;
48+
router.get.withArgs('/:id', 'thingCtrl.show').should.have.been.calledOnce;
4949
});
5050

5151
});
5252

5353
describe('POST /api/things', function() {
5454

5555
it('should route to thing.controller.create', function() {
56-
return router.post.withArgs('/', 'thingCtrl.create').should.have.been.calledOnce;
56+
router.post.withArgs('/', 'thingCtrl.create').should.have.been.calledOnce;
5757
});
5858

5959
});
6060

6161
describe('PUT /api/things/:id', function() {
6262

6363
it('should route to thing.controller.update', function() {
64-
return router.put.withArgs('/:id', 'thingCtrl.update').should.have.been.calledOnce;
64+
router.put.withArgs('/:id', 'thingCtrl.update').should.have.been.calledOnce;
6565
});
6666

6767
});
6868

6969
describe('PATCH /api/things/:id', function() {
7070

7171
it('should route to thing.controller.update', function() {
72-
return router.patch.withArgs('/:id', 'thingCtrl.update').should.have.been.calledOnce;
72+
router.patch.withArgs('/:id', 'thingCtrl.update').should.have.been.calledOnce;
7373
});
7474

7575
});
7676

7777
describe('DELETE /api/things/:id', function() {
7878

7979
it('should route to thing.controller.destroy', function() {
80-
return router.delete.withArgs('/:id', 'thingCtrl.destroy').should.have.been.calledOnce;
80+
router.delete.withArgs('/:id', 'thingCtrl.destroy').should.have.been.calledOnce;
8181
});
8282

8383
});<% } %>

Diff for: app/templates/server/api/user(auth)/index.spec.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var proxyquire = require('proxyquire').noPreserveCache();
3+
var proxyquire = require('proxyquire').noPreserveCache().noCallThru();
44

55
/* user.controller stub */
66
var userCtrl = {
@@ -47,47 +47,47 @@ describe('User API Router:', function() {
4747
describe('GET /api/users', function() {
4848

4949
it('should verify admin role and route to user.controller.index', function() {
50-
return router.get.withArgs('/', 'authService.hasRole.admin', 'userCtrl.index').should.have.been.calledOnce;
50+
router.get.withArgs('/', 'authService.hasRole.admin', 'userCtrl.index').should.have.been.calledOnce;
5151
});
5252

5353
});
5454

5555
describe('DELETE /api/users/:id', function() {
5656

5757
it('should verify admin role and route to user.controller.destroy', function() {
58-
return router.delete.withArgs('/:id', 'authService.hasRole.admin', 'userCtrl.destroy').should.have.been.calledOnce;
58+
router.delete.withArgs('/:id', 'authService.hasRole.admin', 'userCtrl.destroy').should.have.been.calledOnce;
5959
});
6060

6161
});
6262

6363
describe('GET /api/users/me', function() {
6464

6565
it('should be authenticated and route to user.controller.me', function() {
66-
return router.get.withArgs('/me', 'authService.isAuthenticated', 'userCtrl.me').should.have.been.calledOnce;
66+
router.get.withArgs('/me', 'authService.isAuthenticated', 'userCtrl.me').should.have.been.calledOnce;
6767
});
6868

6969
});
7070

7171
describe('PUT /api/users/:id/password', function() {
7272

7373
it('should be authenticated and route to user.controller.changePassword', function() {
74-
return router.put.withArgs('/:id/password', 'authService.isAuthenticated', 'userCtrl.changePassword').should.have.been.calledOnce;
74+
router.put.withArgs('/:id/password', 'authService.isAuthenticated', 'userCtrl.changePassword').should.have.been.calledOnce;
7575
});
7676

7777
});
7878

7979
describe('GET /api/users/:id', function() {
8080

8181
it('should be authenticated and route to user.controller.show', function() {
82-
return router.get.withArgs('/:id', 'authService.isAuthenticated', 'userCtrl.show').should.have.been.calledOnce;
82+
router.get.withArgs('/:id', 'authService.isAuthenticated', 'userCtrl.show').should.have.been.calledOnce;
8383
});
8484

8585
});
8686

8787
describe('POST /api/users', function() {
8888

8989
it('should route to user.controller.create', function() {
90-
return router.post.withArgs('/', 'userCtrl.create').should.have.been.calledOnce;
90+
router.post.withArgs('/', 'userCtrl.create').should.have.been.calledOnce;
9191
});
9292

9393
});

Diff for: app/templates/server/api/user(auth)/user.model.spec.js

+23-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
'use strict';
22

3-
var app = require('../../app');
4-
var User = require('./user.model');
5-
6-
var user = new User({
7-
provider: 'local',
8-
name: 'Fake User',
9-
10-
password: 'password'
3+
var mongoose = require('mongoose'),
4+
config = require('../../config/environment'),
5+
User, user;
6+
7+
before(function() {
8+
// Connect to database
9+
mongoose.connect(config.mongo.uri, config.mongo.options);
10+
11+
User = require('./user.model');
12+
13+
user = new User({
14+
provider: 'local',
15+
name: 'Fake User',
16+
17+
password: 'password'
18+
});
19+
});
20+
21+
after(function() {
22+
// Close database connection
23+
mongoose.connection.close();
1124
});
1225

1326
describe('User Model:', function() {
@@ -56,11 +69,11 @@ describe('User Model:', function() {
5669
describe('.authenticate()', function() {
5770

5871
it("should authenticate user if password is valid", function() {
59-
return user.authenticate('password').should.be.true;
72+
user.authenticate('password').should.be.true;
6073
});
6174

6275
it("should not authenticate user if password is invalid", function() {
63-
return user.authenticate('blah').should.not.be.true;
76+
user.authenticate('blah').should.not.be.true;
6477
});
6578

6679
});

Diff for: endpoint/templates/index.spec.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var proxyquire = require('proxyquire').noPreserveCache();
3+
var proxyquire = require('proxyquire').noPreserveCache().noCallThru();
44

55
/* <%= name %>.controller stub */
66
var <%= name %>Ctrl = {
@@ -37,47 +37,47 @@ describe('<%= classedName %> API Router:', function() {
3737
describe('GET <%= route %>', function() {
3838

3939
it('should route to <%= name %>.controller.index', function() {
40-
return router.get.withArgs('/', '<%= name %>Ctrl.index').should.have.been.calledOnce;
40+
router.get.withArgs('/', '<%= name %>Ctrl.index').should.have.been.calledOnce;
4141
});
4242

4343
});<% if(filters.mongoose) { %>
4444

4545
describe('GET <%= route %>/:id', function() {
4646

4747
it('should route to <%= name %>.controller.show', function() {
48-
return router.get.withArgs('/:id', '<%= name %>Ctrl.show').should.have.been.calledOnce;
48+
router.get.withArgs('/:id', '<%= name %>Ctrl.show').should.have.been.calledOnce;
4949
});
5050

5151
});
5252

5353
describe('POST <%= route %>', function() {
5454

5555
it('should route to <%= name %>.controller.create', function() {
56-
return router.post.withArgs('/', '<%= name %>Ctrl.create').should.have.been.calledOnce;
56+
router.post.withArgs('/', '<%= name %>Ctrl.create').should.have.been.calledOnce;
5757
});
5858

5959
});
6060

6161
describe('PUT <%= route %>/:id', function() {
6262

6363
it('should route to <%= name %>.controller.update', function() {
64-
return router.put.withArgs('/:id', '<%= name %>Ctrl.update').should.have.been.calledOnce;
64+
router.put.withArgs('/:id', '<%= name %>Ctrl.update').should.have.been.calledOnce;
6565
});
6666

6767
});
6868

6969
describe('PATCH <%= route %>/:id', function() {
7070

7171
it('should route to <%= name %>.controller.update', function() {
72-
return router.patch.withArgs('/:id', '<%= name %>Ctrl.update').should.have.been.calledOnce;
72+
router.patch.withArgs('/:id', '<%= name %>Ctrl.update').should.have.been.calledOnce;
7373
});
7474

7575
});
7676

7777
describe('DELETE <%= route %>/:id', function() {
7878

7979
it('should route to <%= name %>.controller.destroy', function() {
80-
return router.delete.withArgs('/:id', '<%= name %>Ctrl.destroy').should.have.been.calledOnce;
80+
router.delete.withArgs('/:id', '<%= name %>Ctrl.destroy').should.have.been.calledOnce;
8181
});
8282

8383
});<% } %>

0 commit comments

Comments
 (0)