Skip to content

Commit

Permalink
Pages: Fixed unused changelog on first page publish
Browse files Browse the repository at this point in the history
Included test to cover.
For #5056
  • Loading branch information
ssddanbrown committed Jun 9, 2024
1 parent c77e873 commit a8ce199
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/Entities/Repos/PageRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public function publishDraft(Page $draft, array $input): Page
$this->updateTemplateStatusAndContentFromInput($draft, $input);
$this->baseRepo->update($draft, $input);

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

Activity::add(ActivityType::PAGE_CREATE, $draft);
Expand Down
26 changes: 26 additions & 0 deletions tests/Entity/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,32 @@ public function test_page_creation_with_markdown_content()
$resp->assertSee('# a title');
}

public function test_page_creation_allows_summary_to_be_set()
{
$book = $this->entities->book();

$this->asEditor()->get($book->getUrl('/create-page'));
$draft = Page::query()->where('book_id', '=', $book->id)
->where('draft', '=', true)->first();

$details = [
'html' => '<h1>a title</h1>',
'name' => 'My page with summary',
'summary' => 'Here is my changelog message for a new page!',
];
$resp = $this->post($book->getUrl("/draft/{$draft->id}"), $details);
$resp->assertRedirect();

$this->assertDatabaseHas('page_revisions', [
'page_id' => $draft->id,
'summary' => 'Here is my changelog message for a new page!',
]);

$draft->refresh();
$resp = $this->get($draft->getUrl('/revisions'));
$resp->assertSee('Here is my changelog message for a new page!');
}

public function test_page_delete()
{
$page = $this->entities->page();
Expand Down

0 comments on commit a8ce199

Please sign in to comment.