From 4bc586141d0ef1c295edcbc548631acc4d7d0068 Mon Sep 17 00:00:00 2001 From: Robert Deutz Date: Thu, 8 May 2025 17:22:15 +0200 Subject: [PATCH 1/2] implement major version check #27 --- app/Jobs/UpdateSite.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Jobs/UpdateSite.php b/app/Jobs/UpdateSite.php index e11286b..a278ae8 100644 --- a/app/Jobs/UpdateSite.php +++ b/app/Jobs/UpdateSite.php @@ -44,6 +44,16 @@ public function handle(): void return; } + // Do not make a major version update + $majorVersionCms = (int) $healthResult->cms_version; + $majorTargetVersion = (int) $this->targetVersion; + + if ($majorVersionCms <> $majorTargetVersion) { + Log::info("No major update for Site: " . $this->site->id); + + return; + } + // Store pre-update response code $this->preUpdateCode = $this->site->getFrontendStatus(); From eea50b9fbc687df58cecda044d7f07af128f98f6 Mon Sep 17 00:00:00 2001 From: Robert Deutz Date: Thu, 8 May 2025 17:59:15 +0200 Subject: [PATCH 2/2] add test --- tests/Unit/Jobs/UpdateSiteTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/Unit/Jobs/UpdateSiteTest.php b/tests/Unit/Jobs/UpdateSiteTest.php index 75c49a3..3e6f283 100644 --- a/tests/Unit/Jobs/UpdateSiteTest.php +++ b/tests/Unit/Jobs/UpdateSiteTest.php @@ -58,6 +58,29 @@ public function testJobQuitsIfNoUpdateIsAvailable() $this->assertTrue(true); } + public function testJobQuitsIfAvailableUpdateWouldBeAMajorUpdate() + { + $site = $this->getSiteMock( + [ + 'checkHealth' => $this->getHealthCheckMock(), + 'getUpdate' => $this->getGetUpdateMock("2.0.0") + ] + ); + + Log::spy(); + + $object = new UpdateSite($site, "2.0.0"); + $object->handle(); + + Log::shouldHaveReceived('info') + ->once() + ->withArgs(function ($message) { + return str_contains($message, 'No major update for Site'); + }); + + $this->assertTrue(true); + } + public function testJobQuitsIfAvailableUpdateDoesNotMatchTargetVersion() { $site = $this->getSiteMock(