diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 311e166..e24e79b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,12 @@ - + + + + + + - - + + - - + + - + - - + + - - - - - - - - - - - - - - + + + + @@ -76,30 +71,20 @@ - - - - - - - - - - - - + + - + - + @@ -109,7 +94,7 @@ - + @@ -119,11 +104,31 @@ - - + + + + + + + + + + + + - - + + + + + + + + + + + + @@ -183,11 +188,13 @@ @@ -197,6 +204,8 @@ + + @@ -346,6 +355,9 @@ test + + test:server + uglify @@ -453,15 +465,25 @@ - + + + @@ -730,12 +810,12 @@ - + - + @@ -782,7 +862,20 @@ - + + + + file://$PROJECT_DIR$/.tmp/routes/restSpec.js + 46 + + + file://$PROJECT_DIR$/.tmp/routes/restSpec.js + 40 + + + - - - - - - - - - - - - - - @@ -1004,6 +1083,7 @@ + @@ -1011,13 +1091,7 @@ - - - - - - - + @@ -1064,13 +1138,6 @@ - - - - - - - @@ -1079,14 +1146,6 @@ - - - - - - - - @@ -1103,17 +1162,6 @@ - - - - - - - - - - - @@ -1143,8 +1191,8 @@ - - + + @@ -1153,7 +1201,10 @@ - + + + + @@ -1165,18 +1216,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - + + + + + + + + + + diff --git a/Gruntfile.js b/Gruntfile.js index e845264..47bd9df 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -522,6 +522,7 @@ require('json-proxy').initialize({}); return grunt.task.run(['karma:unit']); } }); + grunt.registerTask('test:server', 'coffee', 'jasmine_node'); grunt.registerTask('build', ['clean:dist', 'useminPrepare', 'concurrent:dist', 'autoprefixer', 'concat', 'ngmin', 'copy:dist', 'cdnify', 'cssmin', 'uglify', 'rev', 'usemin']); diff --git a/db/angular-cms.0 b/db/angular-cms.0 index b3b061d..787e459 100644 Binary files a/db/angular-cms.0 and b/db/angular-cms.0 differ diff --git a/db/angular-cms.ns b/db/angular-cms.ns index d03d9fb..53c1db5 100644 Binary files a/db/angular-cms.ns and b/db/angular-cms.ns differ diff --git a/routes/rest.js b/routes/rest.js index 7a08f8f..cec5517 100755 --- a/routes/rest.js +++ b/routes/rest.js @@ -216,7 +216,7 @@ var RestResource = { v2index : function(req, res, next) { RestResource.version = 'v2'; res.json({ - message : ' REST API Server ' + RestResource.useversion + message : 'REST API Server ' + RestResource.useversion }); }, //### hashPassword diff --git a/test/routes/restSpec.coffee b/test/routes/restSpec.coffee index 1d888a0..39ef2c5 100644 --- a/test/routes/restSpec.coffee +++ b/test/routes/restSpec.coffee @@ -1,10 +1,39 @@ #Routes Spec request = require("request") -describe 'Testing api endpoint', () -> - it "should respond with hello world", (done) -> - jsonResponse = { message: ' REST API Server v2' } - request "http://localhost:8181/api/v2", (error, response, body) -> - expect(JSON.prase(response.body)).toEqual jsonResponse +endpoint = 'http://localhost:8181/api/v2' + +describe 'Testing: API Server', () -> + it "GET - /api/v2 - should respond with REST API Server v2", (done) -> + jsonResponse = { message: 'REST API Server v2' } + request endpoint, (error, response, body) -> + expect(JSON.parse(response.body)).toEqual jsonResponse + done() + + it "GET - /angular-cms/users - should return a list of users", (done) -> + request "#{endpoint}/angular-cms/users", (error, response, body) -> + expect(JSON.parse(response.body).length).toBeGreaterThan 0 + done() + + it "POST - /angular-cms/users - should create and return object", (done) -> + postData = + "username": "nodetest", + "email": "nodetest@email.com", + "password": "test", + "active": true, + "groups": ["member"], + "_activation": "", + "_key": "", + "created": new Date(), + "modified": new Date(), + "metadata": {"avatar": "", "name": "Node Test User"} + + options = + uri: "#{endpoint}/angular-cms/users" + method: 'POST' + json: postData + request options, (error, response, body) -> + console.log(body) + expect(response.status).toBe 'ok' done()