Skip to content

Commit

Permalink
Merge pull request #619 from lonnylot/issue/custom-basename
Browse files Browse the repository at this point in the history
Custom MasterSupervisor name breaks dashboard
  • Loading branch information
taylorotwell authored Jun 21, 2019
2 parents a6e4a89 + 2f6fcf7 commit ff670ac
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Repositories/RedisSupervisorRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function update(Supervisor $supervisor)
$pipe->hmset(
'supervisor:'.$supervisor->name, [
'name' => $supervisor->name,
'master' => explode(':', $supervisor->name)[0],
'master' => implode(':', explode(':', $supervisor->name, -1)),
'pid' => $supervisor->pid(),
'status' => $supervisor->working ? 'running' : 'paused',
'processes' => $processes,
Expand Down
34 changes: 34 additions & 0 deletions tests/Controller/MasterSupervisorControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,38 @@ public function test_master_supervisor_listing_with_supervisors()
],
]);
}

public function test_master_supervisor_with_custom_name_listing_with_supervisors()
{
$master = new MasterSupervisor;
$master->name = 'risa:production';
resolve(MasterSupervisorRepository::class)->update($master);

$master2 = new MasterSupervisor;
$master2->name = 'risa:production-2';
resolve(MasterSupervisorRepository::class)->update($master2);

$supervisor = new Supervisor(new SupervisorOptions('risa:production:name', 'redis'));
resolve(SupervisorRepository::class)->update($supervisor);

$response = $this->actingAs(new Fakes\User)->get('/horizon/api/masters');

$response->assertJson([
'risa:production' => [
'name' => 'risa:production',
'status' => 'running',
'supervisors' => [
[
'name' => 'risa:production:name',
'master' => 'risa:production',
'status' => 'running',
'processes' => ['redis:default' => 0],
],
],
],
'risa:production-2' => [
'supervisors' => [],
],
]);
}
}

0 comments on commit ff670ac

Please sign in to comment.