@@ -342,6 +342,53 @@ public function testUpdateAssetsWhenCreatingProcess()
342342 $ this ->assertEquals ('Description of the process ' , $ newProcess ->description );
343343 }
344344
345+ public function testProcessCreatedFromTemplateUsesAuthenticatedUserAsOwner ()
346+ {
347+ $ this ->addGlobalSignalProcess ();
348+ $ templateOwner = User::factory ()->create (['is_administrator ' => true ]);
349+ $ this ->user = User::factory ()->create (['is_administrator ' => false ]);
350+
351+ $ processCategory = ProcessCategory::factory ()->create (['status ' => 'ACTIVE ' ]);
352+
353+ $ process = $ this ->createProcess ('process-with-task-screen ' , [
354+ 'name ' => 'Template Owned Process ' ,
355+ 'description ' => 'Template Owned Description ' ,
356+ 'user_id ' => $ templateOwner ->getKey (),
357+ 'process_category_id ' => $ processCategory ->getKey (),
358+ ]);
359+
360+ $ manifest = $ this ->getManifest ('process ' , $ process ->id );
361+
362+ $ template = ProcessTemplates::factory ()->create ([
363+ 'name ' => 'Owner Override Template ' ,
364+ 'description ' => 'Owner Override Template Description ' ,
365+ 'process_id ' => $ process ->id ,
366+ 'process_category_id ' => $ processCategory ->getKey (),
367+ 'manifest ' => json_encode ($ manifest ),
368+ 'user_id ' => $ templateOwner ->getKey (),
369+ 'version ' => '1.0.0 ' ,
370+ ]);
371+
372+ $ route = route ('api.template.create ' , ['type ' => 'process ' , 'id ' => $ template ->id ]);
373+ $ response = $ this ->apiCall ('POST ' , $ route , [
374+ 'user_id ' => $ this ->user ->getKey (),
375+ 'name ' => 'New Process From Template ' ,
376+ 'description ' => 'New Process Description ' ,
377+ 'process_category_id ' => $ processCategory ->getKey (),
378+ 'mode ' => 'copy ' ,
379+ 'version ' => $ template ->version ,
380+ 'saveAssetMode ' => 'saveAllAssets ' ,
381+ ]);
382+
383+ $ response ->assertStatus (200 );
384+
385+ $ processId = $ response ->json ('processId ' );
386+ $ newProcess = Process::findOrFail ($ processId );
387+
388+ $ this ->assertEquals ($ this ->user ->getKey (), $ newProcess ->user_id );
389+ $ this ->assertNotEquals ($ templateOwner ->getKey (), $ newProcess ->user_id );
390+ }
391+
345392 /**
346393 * Tests the fixtures of the private PHP function.
347394 *
0 commit comments