mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-22 12:51:16 +08:00
Chapters API: Added missing book_slug field
Was removed during previous changes, but reflected in response examples. This adds into all standard single chapter responses. For #4765
This commit is contained in:
parent
afbbcafd44
commit
adf1806fea
|
@ -134,8 +134,9 @@ class ChapterApiController extends ApiController
|
|||
$chapter->unsetRelations()->refresh();
|
||||
|
||||
$chapter->load(['tags']);
|
||||
$chapter->makeVisible('description_html')
|
||||
->setAttribute('description_html', $chapter->descriptionHtml());
|
||||
$chapter->makeVisible('description_html');
|
||||
$chapter->setAttribute('description_html', $chapter->descriptionHtml());
|
||||
$chapter->setAttribute('book_slug', $chapter->book()->first()->slug);
|
||||
|
||||
return $chapter;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
"updated_by": 1,
|
||||
"owned_by": 1,
|
||||
"description_html": "<p>This is a <strong>great new chapter<\/strong> that I've created via the API<\/p>",
|
||||
"book_slug": "example-book",
|
||||
"tags": [
|
||||
{
|
||||
"name": "Category",
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
"updated_by": 1,
|
||||
"owned_by": 1,
|
||||
"description_html": "<p>This is an <strong>updated chapter<\/strong> that I've altered via the API<\/p>",
|
||||
"book_slug": "example-book",
|
||||
"tags": [
|
||||
{
|
||||
"name": "Category",
|
||||
|
|
|
@ -22,11 +22,12 @@ class ChaptersApiTest extends TestCase
|
|||
$resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
|
||||
$resp->assertJson(['data' => [
|
||||
[
|
||||
'id' => $firstChapter->id,
|
||||
'name' => $firstChapter->name,
|
||||
'slug' => $firstChapter->slug,
|
||||
'book_id' => $firstChapter->book->id,
|
||||
'priority' => $firstChapter->priority,
|
||||
'id' => $firstChapter->id,
|
||||
'name' => $firstChapter->name,
|
||||
'slug' => $firstChapter->slug,
|
||||
'book_id' => $firstChapter->book->id,
|
||||
'priority' => $firstChapter->priority,
|
||||
'book_slug' => $firstChapter->book->slug,
|
||||
],
|
||||
]]);
|
||||
}
|
||||
|
@ -130,6 +131,7 @@ class ChaptersApiTest extends TestCase
|
|||
$resp->assertJson([
|
||||
'id' => $chapter->id,
|
||||
'slug' => $chapter->slug,
|
||||
'book_slug' => $chapter->book->slug,
|
||||
'created_by' => [
|
||||
'name' => $chapter->createdBy->name,
|
||||
],
|
||||
|
@ -148,6 +150,7 @@ class ChaptersApiTest extends TestCase
|
|||
],
|
||||
],
|
||||
]);
|
||||
$resp->assertJsonMissingPath('book');
|
||||
$resp->assertJsonCount($chapter->pages()->count(), 'pages');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user