]> BookStack Code Mirror - bookstack/commitdiff
Updated update-url command to look at setting values
authorDan Brown <redacted>
Wed, 10 Feb 2021 23:47:58 +0000 (23:47 +0000)
committerDan Brown <redacted>
Wed, 10 Feb 2021 23:47:58 +0000 (23:47 +0000)
For #2546
Need to consider new JSON-array based setting values.

app/Console/Commands/UpdateUrl.php
tests/CommandsTest.php

index b95e277d176f6ba2f50779dd82bdd3badd6c9cb3..0c27f819ccf348415f1aa711c8bcc10a1375e432 100644 (file)
@@ -60,6 +60,7 @@ class UpdateUrl extends Command
             "attachments" => ["path"],
             "pages" => ["html", "text", "markdown"],
             "images" => ["url"],
+            "settings" => ["value"],
             "comments" => ["html", "text"],
         ];
 
index 8c6ea84bf8524e2ec61d1b2284a560147ab760aa..7d4306559c198e85dba00369e69cd2cc036041b0 100644 (file)
@@ -2,7 +2,6 @@
 
 use BookStack\Actions\ActivityType;
 use BookStack\Actions\Comment;
-use BookStack\Actions\CommentRepo;
 use BookStack\Auth\Permissions\JointPermission;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\Models\Page;
@@ -198,6 +197,17 @@ class CommandsTest extends TestCase
         $this->artisan('bookstack:update-url https://cats.example.com');
     }
 
+    public function test_update_url_command_updates_settings()
+    {
+        setting()->put('my-custom-item', 'https://example.com/donkey/cat');
+        $this->artisan('bookstack:update-url https://example.com https://cats.example.com')
+            ->expectsQuestion("This will search for \"https://example.com\" in your database and replace it with  \"https://cats.example.com\".\nAre you sure you want to proceed?", 'y')
+            ->expectsQuestion("This operation could cause issues if used incorrectly. Have you made a backup of your existing database?", 'y');
+
+        $settingVal = setting('my-custom-item');
+        $this->assertEquals('https://cats.example.com/donkey/cat', $settingVal);
+    }
+
     public function test_regenerate_comment_content_command()
     {
         Comment::query()->forceCreate([