mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-12 15:53:46 -04:00
fix(api): save is_auto_deploy_enabled when creating Docker image and Dockerfile applications
Closes #12339 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f751365863
commit
4559d21b4c
@@ -2327,6 +2327,10 @@ class ApplicationsController extends Controller
|
||||
$application->fqdn = generateUrl(server: $server, random: $application->uuid);
|
||||
$application->save();
|
||||
}
|
||||
if (isset($isAutoDeployEnabled)) {
|
||||
$application->settings->is_auto_deploy_enabled = $isAutoDeployEnabled;
|
||||
$application->settings->save();
|
||||
}
|
||||
if (isset($isForceHttpsEnabled)) {
|
||||
$application->settings->is_force_https_enabled = $isForceHttpsEnabled;
|
||||
$application->settings->save();
|
||||
@@ -2458,6 +2462,10 @@ class ApplicationsController extends Controller
|
||||
$application->fqdn = generateUrl(server: $server, random: $application->uuid);
|
||||
$application->save();
|
||||
}
|
||||
if (isset($isAutoDeployEnabled)) {
|
||||
$application->settings->is_auto_deploy_enabled = $isAutoDeployEnabled;
|
||||
$application->settings->save();
|
||||
}
|
||||
if (isset($isForceHttpsEnabled)) {
|
||||
$application->settings->is_force_https_enabled = $isForceHttpsEnabled;
|
||||
$application->settings->save();
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\Environment;
|
||||
use App\Models\InstanceSettings;
|
||||
use App\Models\Project;
|
||||
use App\Models\Server;
|
||||
use App\Models\Team;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
Storage::fake('ssh-keys');
|
||||
InstanceSettings::unguarded(fn () => InstanceSettings::firstOrCreate(['id' => 0]));
|
||||
|
||||
$this->team = Team::factory()->create();
|
||||
$this->user = User::factory()->create();
|
||||
$this->team->members()->attach($this->user->id, ['role' => 'owner']);
|
||||
session(['currentTeam' => $this->team]);
|
||||
|
||||
$this->bearerToken = $this->user->createToken('auto-deploy-api-test', ['*'])->plainTextToken;
|
||||
$this->server = Server::factory()->create(['team_id' => $this->team->id]);
|
||||
$this->project = Project::factory()->create(['team_id' => $this->team->id]);
|
||||
$this->environment = Environment::factory()->create(['project_id' => $this->project->id]);
|
||||
});
|
||||
|
||||
describe('application creation endpoints is_auto_deploy_enabled', function () {
|
||||
test('stores the requested auto deploy setting', function (string $endpoint, array $payload, bool $isAutoDeployEnabled) {
|
||||
$response = $this->withHeaders(['Authorization' => 'Bearer '.$this->bearerToken])
|
||||
->postJson("/api/v1/applications/{$endpoint}", [
|
||||
'project_uuid' => $this->project->uuid,
|
||||
'environment_uuid' => $this->environment->uuid,
|
||||
'server_uuid' => $this->server->uuid,
|
||||
'is_auto_deploy_enabled' => $isAutoDeployEnabled,
|
||||
'instant_deploy' => false,
|
||||
'autogenerate_domain' => false,
|
||||
...$payload,
|
||||
])
|
||||
->assertCreated();
|
||||
|
||||
$application = Application::where('uuid', $response->json('uuid'))->firstOrFail();
|
||||
|
||||
expect($application->settings->is_auto_deploy_enabled)->toBe($isAutoDeployEnabled);
|
||||
})->with([
|
||||
'Docker image' => ['dockerimage', [
|
||||
'docker_registry_image_name' => 'nginx',
|
||||
'docker_registry_image_tag' => 'alpine',
|
||||
'ports_exposes' => '80',
|
||||
]],
|
||||
'Dockerfile' => ['dockerfile', [
|
||||
'dockerfile' => base64_encode("FROM nginx:alpine\nEXPOSE 80"),
|
||||
]],
|
||||
'public repository' => ['public', [
|
||||
'git_repository' => 'https://gitlab.com/coolify/auto-deploy-test',
|
||||
'git_branch' => 'main',
|
||||
'build_pack' => 'dockerfile',
|
||||
'ports_exposes' => '3000',
|
||||
]],
|
||||
])->with([
|
||||
'disabled' => false,
|
||||
'enabled' => true,
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user