File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,12 @@ class FoldersMoveCommand extends BoxCommand {
1616 updates . etag = flags . etag ;
1717 }
1818
19+ if ( flags [ 'owned-by' ] ) {
20+ updates . owned_by = {
21+ id : flags [ 'owned-by' ] ,
22+ } ;
23+ }
24+
1925 let movedFolder = await this . client . folders . update ( args . id , updates ) ;
2026 await this . output ( movedFolder ) ;
2127 }
@@ -28,6 +34,7 @@ FoldersMoveCommand._endpoint = 'put_folders_id move';
2834FoldersMoveCommand . flags = {
2935 ...BoxCommand . flags ,
3036 etag : Flags . string ( { description : 'Only move if etag value matches' } ) ,
37+ 'owned-by' : Flags . string ( { description : 'ID of the user to own the folder' } ) ,
3138} ;
3239
3340FoldersMoveCommand . args = {
Original file line number Diff line number Diff line change @@ -136,13 +136,22 @@ describe('Folders', () => {
136136 describe ( 'folders:move' , ( ) => {
137137 let folderId = '0' ,
138138 parentFolderId = '987654321' ,
139+ ownedById = '1234567890' ,
139140 moveFixture = getFixture ( 'folders/put_folders_id' ) ,
140141 yamlOutput = getFixture ( 'output/folders_move_yaml.txt' ) ;
141142
142143 let moveBody = {
143144 parent : {
144145 id : parentFolderId
145146 }
147+ } ,
148+ moveBodyWithOwnedBy = {
149+ parent : {
150+ id : parentFolderId
151+ } ,
152+ owned_by : {
153+ id : ownedById
154+ }
146155 } ;
147156
148157 test
@@ -205,6 +214,24 @@ describe('Folders', () => {
205214 let msg = 'Unexpected API Response [412 Precondition Failed | 1wne91fxf8871ide] precondition_failed - The resource has been modified. Please retrieve the resource again and retry' ;
206215 assert . equal ( ctx . stderr , `${ msg } ${ os . EOL } ` ) ;
207216 } ) ;
217+
218+ test
219+ . nock ( TEST_API_ROOT , api => api
220+ . put ( `/2.0/folders/${ folderId } ` , moveBodyWithOwnedBy )
221+ . reply ( 200 , moveFixture )
222+ )
223+ . stdout ( )
224+ . command ( [
225+ 'folders:move' ,
226+ folderId ,
227+ parentFolderId ,
228+ `--owned-by=${ ownedById } ` ,
229+ '--json' ,
230+ '--token=test'
231+ ] )
232+ . it ( 'should move a folder to a different folder and set the owner' , ctx => {
233+ assert . equal ( ctx . stdout , moveFixture ) ;
234+ } ) ;
208235 } ) ;
209236
210237 describe ( 'folders:delete' , ( ) => {
You can’t perform that action at this time.
0 commit comments