Skip to content

Commit

Permalink
Fix non empty API response where empty is stated
Browse files Browse the repository at this point in the history
remp/remp#1378
  • Loading branch information
rootpd committed Aug 22, 2024
1 parent fca8e09 commit cf3bfd4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- When editing newsletter list, only new users will be subscribed to edited newsletter list.
- Added article url support to DailyMinuteGenerator. remp/remp#1370
- Added ability to export sent emails stats in `ListPresenter`. remp/remp#1362
- Fixed Delete User API response not being actually as empty as HTTP code states. remp/remp#1378
## Archive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Tomaj\NetteApi\Params\RawInputParam;
use Tomaj\NetteApi\Response\JsonApiResponse;
use Tomaj\NetteApi\Response\ResponseInterface;
use Tomaj\NetteApi\Response\TextApiResponse;

class UserDeleteApiHandler extends BaseHandler
{
Expand Down Expand Up @@ -60,6 +61,6 @@ public function handle(array $params): ResponseInterface
]);
}

return new JsonApiResponse(IResponse::S204_NoContent, []);
return new TextApiResponse(IResponse::S204_NoContent, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Remp\MailerModule\Repositories\JobQueueRepository;
use Tests\Feature\Api\BaseApiHandlerTestCase;
use Tomaj\NetteApi\Response\JsonApiResponse;
use Tomaj\NetteApi\Response\TextApiResponse;

class UserDeleteApiHandlerTest extends BaseApiHandlerTestCase
{
Expand Down Expand Up @@ -79,13 +80,11 @@ public function testUserDataDeletedSuccess()
])
];

/** @var JsonApiResponse $response */
/** @var TextApiResponse $response */
$response = $this->handler->handle($params);
$payload = $response->getPayload();

$this->assertInstanceOf(JsonApiResponse::class, $response);
$this->assertInstanceOf(TextApiResponse::class, $response);
$this->assertEquals(IResponse::S204_NoContent, $response->getCode());
$this->assertEmpty($payload);

// check user data after removal; check if correct user was removed (has zero data); other two users should be untouched
$this->assertEquals(2, $this->autoLoginTokensRepository->totalCount());
Expand Down

0 comments on commit cf3bfd4

Please sign in to comment.