@@ -66,6 +66,7 @@ describe('Project', () => {
66
66
details : { } ,
67
67
createdBy : 1 ,
68
68
updatedBy : 1 ,
69
+ templateId : 1 ,
69
70
lastActivityAt : 1 ,
70
71
lastActivityUserId : '1' ,
71
72
createdAt : '2016-06-30 00:33:07+00' ,
@@ -79,6 +80,7 @@ describe('Project', () => {
79
80
details : { } ,
80
81
createdBy : 1 ,
81
82
updatedBy : 1 ,
83
+ templateId : 1 ,
82
84
lastActivityAt : 1 ,
83
85
lastActivityUserId : '1' ,
84
86
createdAt : '2016-06-30 00:33:07+00' ,
@@ -91,6 +93,7 @@ describe('Project', () => {
91
93
details : { } ,
92
94
createdBy : 1 ,
93
95
updatedBy : 1 ,
96
+ templateId : 1 ,
94
97
lastActivityAt : 1 ,
95
98
lastActivityUserId : '1' ,
96
99
createdAt : '2016-06-30 00:33:07+00' ,
@@ -179,6 +182,84 @@ describe('Project', () => {
179
182
} ) ;
180
183
} ) ;
181
184
185
+ it ( 'should not update the templateId for admin' , ( done ) => {
186
+ request ( server )
187
+ . patch ( `/v4/projects/${ project1 . id } ` )
188
+ . set ( {
189
+ Authorization : `Bearer ${ testUtil . jwts . admin } ` ,
190
+ } )
191
+ . send ( {
192
+ param : {
193
+ templateId : '2' ,
194
+ } ,
195
+ } )
196
+ . expect ( 'Content-Type' , / j s o n / )
197
+ . expect ( 200 )
198
+ . end ( ( err , res ) => {
199
+ if ( err ) {
200
+ done ( err ) ;
201
+ } else {
202
+ const result = res . body . result ;
203
+ result . success . should . be . true ;
204
+ result . status . should . equal ( 200 ) ;
205
+ result . content . templateId . should . not . equal ( '2' ) ;
206
+ done ( ) ;
207
+ }
208
+ } ) ;
209
+ } ) ;
210
+
211
+ it ( 'should not update the templateId for manager' , ( done ) => {
212
+ request ( server )
213
+ . patch ( `/v4/projects/${ project1 . id } ` )
214
+ . set ( {
215
+ Authorization : `Bearer ${ testUtil . jwts . manager } ` ,
216
+ } )
217
+ . send ( {
218
+ param : {
219
+ templateId : '2' ,
220
+ } ,
221
+ } )
222
+ . expect ( 'Content-Type' , / j s o n / )
223
+ . expect ( 200 )
224
+ . end ( ( err , res ) => {
225
+ if ( err ) {
226
+ done ( err ) ;
227
+ } else {
228
+ const result = res . body . result ;
229
+ result . success . should . be . true ;
230
+ result . status . should . equal ( 200 ) ;
231
+ result . content . templateId . should . not . equal ( '2' ) ;
232
+ done ( ) ;
233
+ }
234
+ } ) ;
235
+ } ) ;
236
+
237
+ it ( 'should not update the templateId for user' , ( done ) => {
238
+ request ( server )
239
+ . patch ( `/v4/projects/${ project1 . id } ` )
240
+ . set ( {
241
+ Authorization : `Bearer ${ testUtil . jwts . member } ` ,
242
+ } )
243
+ . send ( {
244
+ param : {
245
+ templateId : '2' ,
246
+ } ,
247
+ } )
248
+ . expect ( 'Content-Type' , / j s o n / )
249
+ . expect ( 403 )
250
+ . end ( ( err , res ) => {
251
+ if ( err ) {
252
+ done ( err ) ;
253
+ } else {
254
+ const result = res . body . result ;
255
+ result . success . should . be . false ;
256
+ result . status . should . equal ( 403 ) ;
257
+ result . content . message . should . equal ( 'You do not have permissions to perform this action' ) ;
258
+ done ( ) ;
259
+ }
260
+ } ) ;
261
+ } ) ;
262
+
182
263
it ( 'should return 200 if topcoder manager user will update a project' , ( done ) => {
183
264
request ( server )
184
265
. patch ( `/v4/projects/${ project1 . id } ` )
0 commit comments