added status restriction
This commit is contained in:
@@ -40,7 +40,8 @@ class ProjectBoardSettingsControllerTest extends TestCase
|
||||
->component('projects/settings/Board')
|
||||
->where('project.id', $project->id)
|
||||
->where('backlogTicketStatuses.0.name', 'Backlog')
|
||||
->where('boardColumns.0.name', 'Todo'),
|
||||
->where('boardColumns.0.name', 'Todo')
|
||||
->where('ticketStatuses.0.name', 'Backlog'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -205,7 +206,7 @@ class ProjectBoardSettingsControllerTest extends TestCase
|
||||
|
||||
$this->assertSame($boardColumn->id, $newStatus->board_column_id);
|
||||
$this->assertSame('ready-for-qa', $newStatus->slug);
|
||||
$this->assertTrue($defaultStatus->allowedTargetStatuses()->whereKey($newStatus->id)->exists());
|
||||
$this->assertFalse($defaultStatus->allowedTargetStatuses()->whereKey($newStatus->id)->exists());
|
||||
|
||||
$this->actingAs($user)
|
||||
->patch(route('projects.settings.board.statuses.update', [$project, $newStatus]), [
|
||||
@@ -238,6 +239,94 @@ class ProjectBoardSettingsControllerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure authorized users can configure the allowed move targets for a status.
|
||||
*/
|
||||
public function test_users_with_edit_permission_can_update_ticket_status_transitions(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
'key' => 'CORE',
|
||||
]);
|
||||
$this->syncProjectPermissions($project, $user, ['edit']);
|
||||
|
||||
$sourceStatus = TicketStatus::factory()->for($project)->create([
|
||||
'name' => 'Progress',
|
||||
'position' => 1,
|
||||
]);
|
||||
$reviewStatus = TicketStatus::factory()->for($project)->create([
|
||||
'name' => 'Review',
|
||||
'position' => 2,
|
||||
]);
|
||||
$doneStatus = TicketStatus::factory()->for($project)->create([
|
||||
'name' => 'Done',
|
||||
'position' => 3,
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->patch(route('projects.settings.board.statuses.transitions.update', [$project, $sourceStatus]), [
|
||||
'allowed_ticket_status_ids' => [$reviewStatus->id, $doneStatus->id],
|
||||
])
|
||||
->assertRedirect(route('projects.settings.board', $project))
|
||||
->assertSessionHas('status', 'Progress move targets were updated.');
|
||||
|
||||
$this->assertEqualsCanonicalizing(
|
||||
[$reviewStatus->id, $doneStatus->id],
|
||||
$sourceStatus->allowedTargetStatuses()->get()->pluck('id')->all(),
|
||||
);
|
||||
|
||||
$this->actingAs($user)
|
||||
->patch(route('projects.settings.board.statuses.transitions.update', [$project, $sourceStatus]), [])
|
||||
->assertRedirect(route('projects.settings.board', $project))
|
||||
->assertSessionHas('status', 'Progress move targets were updated.');
|
||||
|
||||
$this->assertCount(0, $sourceStatus->allowedTargetStatuses()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure transition updates only accept targets from the same project and never the source status itself.
|
||||
*/
|
||||
public function test_ticket_status_transition_updates_reject_foreign_and_self_targets(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
'key' => 'CORE',
|
||||
]);
|
||||
$otherProject = Project::factory()->create([
|
||||
'key' => 'EXT',
|
||||
]);
|
||||
$this->syncProjectPermissions($project, $user, ['edit']);
|
||||
|
||||
$sourceStatus = TicketStatus::factory()->for($project)->create([
|
||||
'name' => 'Progress',
|
||||
'position' => 1,
|
||||
]);
|
||||
$foreignStatus = TicketStatus::factory()->for($otherProject)->create([
|
||||
'name' => 'External review',
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->from(route('projects.settings.board', $project))
|
||||
->patch(route('projects.settings.board.statuses.transitions.update', [$project, $sourceStatus]), [
|
||||
'allowed_ticket_status_ids' => [$foreignStatus->id],
|
||||
])
|
||||
->assertRedirect(route('projects.settings.board', $project))
|
||||
->assertSessionHasErrors('allowed_ticket_status_ids.0');
|
||||
|
||||
$this->assertCount(0, $sourceStatus->allowedTargetStatuses()->get());
|
||||
|
||||
$this->actingAs($user)
|
||||
->from(route('projects.settings.board', $project))
|
||||
->patch(route('projects.settings.board.statuses.transitions.update', [$project, $sourceStatus]), [
|
||||
'allowed_ticket_status_ids' => [$sourceStatus->id],
|
||||
])
|
||||
->assertRedirect(route('projects.settings.board', $project))
|
||||
->assertSessionHasErrors('allowed_ticket_status_ids');
|
||||
|
||||
$this->assertCount(0, $sourceStatus->allowedTargetStatuses()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the last status in a column or backlog cannot be deleted.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user