added status restriction
This commit is contained in:
@@ -51,9 +51,9 @@ class TicketStatusTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure new statuses can move to each other through the transition relation.
|
||||
* Ensure new statuses do not allow moves until transitions are configured.
|
||||
*/
|
||||
public function test_ticket_statuses_create_allowed_transition_relations(): void
|
||||
public function test_ticket_statuses_do_not_create_allowed_transition_relations_by_default(): void
|
||||
{
|
||||
$project = Project::factory()->create();
|
||||
$backlogStatus = TicketStatus::factory()->for($project)->create([
|
||||
@@ -65,8 +65,38 @@ class TicketStatusTest extends TestCase
|
||||
'position' => 2,
|
||||
]);
|
||||
|
||||
$this->assertTrue($backlogStatus->allowedTargetStatuses()->whereKey($readyStatus->id)->exists());
|
||||
$this->assertTrue($readyStatus->allowedTargetStatuses()->whereKey($backlogStatus->id)->exists());
|
||||
$this->assertFalse($backlogStatus->allowedTargetStatuses()->whereKey($readyStatus->id)->exists());
|
||||
$this->assertFalse($readyStatus->allowedTargetStatuses()->whereKey($backlogStatus->id)->exists());
|
||||
$this->assertCount(0, $backlogStatus->allowedTargetStatuses);
|
||||
$this->assertCount(0, $readyStatus->allowedTargetStatuses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure allowed status moves are controlled by the transition relation.
|
||||
*/
|
||||
public function test_ticket_statuses_sync_allowed_transition_relations(): void
|
||||
{
|
||||
$project = Project::factory()->create();
|
||||
$backlogStatus = TicketStatus::factory()->for($project)->create([
|
||||
'name' => 'Backlog',
|
||||
'position' => 1,
|
||||
]);
|
||||
$readyStatus = TicketStatus::factory()->for($project)->create([
|
||||
'name' => 'Ready',
|
||||
'position' => 2,
|
||||
]);
|
||||
|
||||
$backlogStatus->allowedTargetStatuses()->sync([$readyStatus->id]);
|
||||
|
||||
$this->assertSame(
|
||||
[$readyStatus->id],
|
||||
$backlogStatus->allowedTargetStatuses()->get()->pluck('id')->all(),
|
||||
);
|
||||
$this->assertFalse($readyStatus->allowedTargetStatuses()->whereKey($backlogStatus->id)->exists());
|
||||
|
||||
$backlogStatus->allowedTargetStatuses()->sync([]);
|
||||
|
||||
$this->assertCount(0, $backlogStatus->allowedTargetStatuses()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user