From: Dan Brown Date: Wed, 10 Feb 2021 23:47:58 +0000 (+0000) Subject: Updated update-url command to look at setting values X-Git-Tag: v21.04~1^2~11^2~44 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/ae353bb3f45dc9e667c68c4dfbd5ea7b6210fcfb Updated update-url command to look at setting values For #2546 Need to consider new JSON-array based setting values. --- diff --git a/app/Console/Commands/UpdateUrl.php b/app/Console/Commands/UpdateUrl.php index b95e277d1..0c27f819c 100644 --- a/app/Console/Commands/UpdateUrl.php +++ b/app/Console/Commands/UpdateUrl.php @@ -60,6 +60,7 @@ class UpdateUrl extends Command "attachments" => ["path"], "pages" => ["html", "text", "markdown"], "images" => ["url"], + "settings" => ["value"], "comments" => ["html", "text"], ]; diff --git a/tests/CommandsTest.php b/tests/CommandsTest.php index 8c6ea84bf..7d4306559 100644 --- a/tests/CommandsTest.php +++ b/tests/CommandsTest.php @@ -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([