]> BookStack Code Mirror - bookstack/commitdiff
Pages: Fixed unused changelog on first page publish
authorDan Brown <redacted>
Sun, 9 Jun 2024 16:18:23 +0000 (17:18 +0100)
committerDan Brown <redacted>
Sun, 9 Jun 2024 16:18:23 +0000 (17:18 +0100)
Included test to cover.
For #5056

app/Entities/Repos/PageRepo.php
tests/Entity/PageTest.php

index 2526b6c445d168757db794b875c5ce6263a37cc3..be139b0509ffae0c2ffead4d7fa06ade070ee4bf 100644 (file)
@@ -77,7 +77,8 @@ class PageRepo
         $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);
index daad82e76dc5cbf586bf80eb59290da31ef3436d..b96d455eb253cec53e09c5a13ad5eca89fd53e07 100644 (file)
@@ -86,6 +86,32 @@ class PageTest extends TestCase
         $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();