]> BookStack Code Mirror - bookstack/commitdiff
Comments: Removed remaining uses of redundant 'text' field
authorDan Brown <redacted>
Wed, 31 Jan 2024 16:35:58 +0000 (16:35 +0000)
committerDan Brown <redacted>
Wed, 31 Jan 2024 16:35:58 +0000 (16:35 +0000)
Opened #4821 to remove the DB field in a few releases time.

app/Activity/Models/Comment.php
database/factories/Activity/Models/CommentFactory.php
tests/Entity/CommentTest.php
tests/Permissions/RolePermissionsTest.php

index 038788afb9d82f2fcff309c0ad3f12dede873a3e..7d1c54646c1f6c8f77cdd80bb32be185a6fd760d 100644 (file)
@@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
 
 /**
  * @property int      $id
- * @property string   $text
+ * @property string   $text - Deprecated & now unused (#4821)
  * @property string   $html
  * @property int|null $parent_id  - Relates to local_id, not id
  * @property int      $local_id
@@ -25,7 +25,7 @@ class Comment extends Model implements Loggable
     use HasFactory;
     use HasCreatorAndUpdater;
 
-    protected $fillable = ['text', 'parent_id'];
+    protected $fillable = ['parent_id'];
     protected $appends = ['created', 'updated'];
 
     /**
index 35d6db9bdca01a904be82a0fd7a2561e6807734e..efbd183b31d8cd75dd4a18281e3948f7353878b9 100644 (file)
@@ -25,7 +25,6 @@ class CommentFactory extends Factory
 
         return [
             'html'      => $html,
-            'text'      => $text,
             'parent_id' => null,
             'local_id'  => 1,
         ];
index 76e014e80dc340176891128db051a5c40cfdd2d6..eb4bccb7cae955b81fa9159b7456e4f2169be8cf 100644 (file)
@@ -18,10 +18,10 @@ class CommentTest extends TestCase
         $resp = $this->postJson("/comment/$page->id", $comment->getAttributes());
 
         $resp->assertStatus(200);
-        $resp->assertSee($comment->text);
+        $resp->assertSee($comment->html, false);
 
         $pageResp = $this->get($page->getUrl());
-        $pageResp->assertSee($comment->text);
+        $pageResp->assertSee($comment->html, false);
 
         $this->assertDatabaseHas('comments', [
             'local_id'    => 1,
index ccb158faf5f3859fc59185f1861d1d5310ccd278..d3146bd47bd9e838384886a17aae4dced9000563 100644 (file)
@@ -738,16 +738,12 @@ class RolePermissionsTest extends TestCase
 
     private function addComment(Page $page): TestResponse
     {
-        $comment = Comment::factory()->make();
-
-        return $this->postJson("/comment/$page->id", $comment->only('text', 'html'));
+        return $this->postJson("/comment/$page->id", ['html' => '<p>New comment content</p>']);
     }
 
     private function updateComment(Comment $comment): TestResponse
     {
-        $commentData = Comment::factory()->make();
-
-        return $this->putJson("/comment/{$comment->id}", $commentData->only('text', 'html'));
+        return $this->putJson("/comment/{$comment->id}", ['html' => '<p>Updated comment content</p>']);
     }
 
     private function deleteComment(Comment $comment): TestResponse
Morty Proxy This is a proxified and sanitized view of the page, visit original site.