Skip to content

Commit a8ce199

Browse files
committed
Pages: Fixed unused changelog on first page publish
Included test to cover. For BookStackApp#5056
1 parent c77e873 commit a8ce199

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

app/Entities/Repos/PageRepo.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public function publishDraft(Page $draft, array $input): Page
7777
$this->updateTemplateStatusAndContentFromInput($draft, $input);
7878
$this->baseRepo->update($draft, $input);
7979

80-
$this->revisionRepo->storeNewForPage($draft, trans('entities.pages_initial_revision'));
80+
$summary = trim($input['summary'] ?? '') ?: trans('entities.pages_initial_revision');
81+
$this->revisionRepo->storeNewForPage($draft, $summary);
8182
$draft->refresh();
8283

8384
Activity::add(ActivityType::PAGE_CREATE, $draft);

tests/Entity/PageTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,32 @@ public function test_page_creation_with_markdown_content()
8686
$resp->assertSee('# a title');
8787
}
8888

89+
public function test_page_creation_allows_summary_to_be_set()
90+
{
91+
$book = $this->entities->book();
92+
93+
$this->asEditor()->get($book->getUrl('/create-page'));
94+
$draft = Page::query()->where('book_id', '=', $book->id)
95+
->where('draft', '=', true)->first();
96+
97+
$details = [
98+
'html' => '<h1>a title</h1>',
99+
'name' => 'My page with summary',
100+
'summary' => 'Here is my changelog message for a new page!',
101+
];
102+
$resp = $this->post($book->getUrl("/draft/{$draft->id}"), $details);
103+
$resp->assertRedirect();
104+
105+
$this->assertDatabaseHas('page_revisions', [
106+
'page_id' => $draft->id,
107+
'summary' => 'Here is my changelog message for a new page!',
108+
]);
109+
110+
$draft->refresh();
111+
$resp = $this->get($draft->getUrl('/revisions'));
112+
$resp->assertSee('Here is my changelog message for a new page!');
113+
}
114+
89115
public function test_page_delete()
90116
{
91117
$page = $this->entities->page();

0 commit comments

Comments
 (0)