File tree Expand file tree Collapse file tree 3 files changed +72
-0
lines changed
test/integration/controllers Expand file tree Collapse file tree 3 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * CustomController
3+ *
4+ * @description :: Server-side logic for managing customs
5+ * @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
6+ */
7+
8+ module . exports = {
9+
10+ } ;
11+
Original file line number Diff line number Diff line change 1+ /**
2+ * Custom.js
3+ *
4+ * @description :: TODO: You might write a short summary of how this model works and what it represents here.
5+ * @docs :: http://sailsjs.org/documentation/concepts/models-and-orm/models
6+ */
7+
8+ module . exports = {
9+
10+ autoPK : false ,
11+
12+ attributes : {
13+ key : {
14+ type : 'integer' ,
15+ autoIncrement : true ,
16+ primaryKey : true ,
17+ unique : true ,
18+ index : true
19+ }
20+ } ,
21+
22+ autoCreatedAt : false ,
23+ autoUpdatedAt : false
24+ } ;
Original file line number Diff line number Diff line change 1+ var clone = require ( 'clone' ) ;
2+ var request = require ( 'supertest' ) ;
3+ var JSONAPIValidator = require ( 'jsonapi-validator' ) . Validator ;
4+
5+ validateJSONapi = function ( res ) {
6+ var validator = new JSONAPIValidator ( ) ;
7+
8+ validator . validate ( res . body ) ;
9+ } ;
10+
11+ describe ( "Custom primary key name" , function ( ) {
12+
13+ describe ( "POST /customs" , function ( ) {
14+
15+ it ( 'Should return a unique identifier from custom sails primaryKey' , function ( done ) {
16+
17+ var categoryToCreate = {
18+ 'data' : {
19+ 'attributes' : {
20+ } ,
21+ 'type' :'customs'
22+ }
23+ } ;
24+
25+ categoryCreated = clone ( categoryToCreate ) ;
26+ categoryCreated . data . id = "1" ;
27+
28+ request ( sails . hooks . http . app )
29+ . post ( '/customs' )
30+ . send ( categoryToCreate )
31+ . expect ( 201 )
32+ . expect ( validateJSONapi )
33+ . expect ( categoryCreated )
34+ . end ( done ) ;
35+ } ) ;
36+ } ) ;
37+ } ) ;
You can’t perform that action at this time.
0 commit comments