From 3e16a6c5584379090dcc493817ee1b064c65df7d Mon Sep 17 00:00:00 2001 From: Spitfire Date: Wed, 22 May 2024 11:37:14 -0600 Subject: [PATCH 1/2] Fixed issues with the API and API Tests --- app/Http/Controllers/Api/v1/AbilityApiController.php | 1 + app/Http/Controllers/Api/v1/ApiController.php | 1 + app/Http/Controllers/Api/v1/BookmarkApiController.php | 2 +- app/Http/Controllers/Api/v1/CalendarApiController.php | 1 + app/Http/Controllers/Api/v1/CreatureApiController.php | 2 +- phpunit.xml | 1 + tests/Feature/Entities/AbilityTest.php | 7 ------- 7 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Api/v1/AbilityApiController.php b/app/Http/Controllers/Api/v1/AbilityApiController.php index 7b43a91fbc..d3ab0eaf40 100644 --- a/app/Http/Controllers/Api/v1/AbilityApiController.php +++ b/app/Http/Controllers/Api/v1/AbilityApiController.php @@ -47,6 +47,7 @@ public function store(Request $request, Campaign $campaign) $data['campaign_id'] = $campaign->id; $model = Ability::create($data); $this->crudSave($model); + return new Resource($model); } diff --git a/app/Http/Controllers/Api/v1/ApiController.php b/app/Http/Controllers/Api/v1/ApiController.php index 57211ed2ee..12bdf0dce2 100644 --- a/app/Http/Controllers/Api/v1/ApiController.php +++ b/app/Http/Controllers/Api/v1/ApiController.php @@ -23,5 +23,6 @@ protected function crudSave(MiscModel $model) $model->entity->touch(); } } + $model->refresh(); } } diff --git a/app/Http/Controllers/Api/v1/BookmarkApiController.php b/app/Http/Controllers/Api/v1/BookmarkApiController.php index 0d19758768..8469230e58 100644 --- a/app/Http/Controllers/Api/v1/BookmarkApiController.php +++ b/app/Http/Controllers/Api/v1/BookmarkApiController.php @@ -46,7 +46,7 @@ public function store(Request $request, Campaign $campaign) /** @var Bookmark $model */ $model = Bookmark::create($data); $this->crudSave($model); - $model->refresh(); + return new Resource($model); } diff --git a/app/Http/Controllers/Api/v1/CalendarApiController.php b/app/Http/Controllers/Api/v1/CalendarApiController.php index 18f6047ac4..25d34ac3bb 100644 --- a/app/Http/Controllers/Api/v1/CalendarApiController.php +++ b/app/Http/Controllers/Api/v1/CalendarApiController.php @@ -57,6 +57,7 @@ public function store(Request $request, Campaign $campaign) /** @var Calendar $model */ $model = Calendar::create($data); $this->crudSave($model); + return new Resource($model); } diff --git a/app/Http/Controllers/Api/v1/CreatureApiController.php b/app/Http/Controllers/Api/v1/CreatureApiController.php index 780944edbe..10623ebf8a 100644 --- a/app/Http/Controllers/Api/v1/CreatureApiController.php +++ b/app/Http/Controllers/Api/v1/CreatureApiController.php @@ -48,7 +48,7 @@ public function store(Request $request, Campaign $campaign) $data['campaign_id'] = $campaign->id; $model = Creature::create($data); $this->crudSave($model); - $model->refresh(); + return new Resource($model); } diff --git a/phpunit.xml b/phpunit.xml index 393f2d1120..b2e382bd31 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -25,5 +25,6 @@ + diff --git a/tests/Feature/Entities/AbilityTest.php b/tests/Feature/Entities/AbilityTest.php index bf32416e79..0cfe60f5bb 100644 --- a/tests/Feature/Entities/AbilityTest.php +++ b/tests/Feature/Entities/AbilityTest.php @@ -2,13 +2,6 @@ use App\Models\Ability; -it('POSTS an invalid ability form') - ->asUser() - ->withCampaign() - ->postJson('/api/1.0/campaigns/1/abilities', []) - ->assertStatus(422) -; - it('POSTS a new ability') ->asUser() ->withCampaign() From 166e9a305521b561237fa5bb430fd09603a473dd Mon Sep 17 00:00:00 2001 From: Itzamna Serrano <72818019+spitfire305@users.noreply.github.com> Date: Wed, 22 May 2024 14:36:26 -0600 Subject: [PATCH 2/2] Added back code deleted accidentally --- tests/Feature/Entities/AbilityTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Feature/Entities/AbilityTest.php b/tests/Feature/Entities/AbilityTest.php index 0cfe60f5bb..bf32416e79 100644 --- a/tests/Feature/Entities/AbilityTest.php +++ b/tests/Feature/Entities/AbilityTest.php @@ -2,6 +2,13 @@ use App\Models\Ability; +it('POSTS an invalid ability form') + ->asUser() + ->withCampaign() + ->postJson('/api/1.0/campaigns/1/abilities', []) + ->assertStatus(422) +; + it('POSTS a new ability') ->asUser() ->withCampaign()