mirror of
https://github.com/flarum/core.git
synced 2025-08-18 06:11:23 +02:00
refactor: remove listing of posts in the show discussion endpoint (#4067)
This commit is contained in:
@@ -50,11 +50,6 @@ return [
|
||||
}
|
||||
),
|
||||
|
||||
(new Extend\ApiResource(Resource\DiscussionResource::class))
|
||||
->endpoint(Endpoint\Show::class, function (Endpoint\Show $endpoint): Endpoint\Endpoint {
|
||||
return $endpoint->addDefaultInclude(['posts.likes']);
|
||||
}),
|
||||
|
||||
(new Extend\Event())
|
||||
->listen(PostWasLiked::class, Listener\SendNotificationWhenPostIsLiked::class)
|
||||
->listen(PostWasUnliked::class, Listener\SendNotificationWhenPostIsUnliked::class)
|
||||
|
@@ -173,9 +173,10 @@ class ListPostsTest extends TestCase
|
||||
{
|
||||
// Show discussion endpoint
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/discussions/100', [
|
||||
$this->request('GET', '/api/posts', [
|
||||
'authenticatedAs' => 2,
|
||||
])->withQueryParams([
|
||||
'filter' => ['discussion' => 100],
|
||||
'include' => $include,
|
||||
])
|
||||
);
|
||||
@@ -184,7 +185,7 @@ class ListPostsTest extends TestCase
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode(), $body);
|
||||
|
||||
$included = json_decode($body, true)['included'] ?? [];
|
||||
$included = json_decode($body, true)['data'] ?? [];
|
||||
|
||||
$likes = collect($included)
|
||||
->where('type', 'posts')
|
||||
@@ -206,8 +207,7 @@ class ListPostsTest extends TestCase
|
||||
public static function likesIncludeProvider(): array
|
||||
{
|
||||
return [
|
||||
['posts,posts.likes'],
|
||||
['posts.likes'],
|
||||
['likes'],
|
||||
[null],
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user