Fixed FD-54447 - superuser on user bulk edit check for groups

This commit is contained in:
snipe
2026-05-21 16:12:19 +01:00
parent 6a68a38d71
commit cd5716d66d
@@ -2,7 +2,7 @@
namespace Tests\Feature\Users\Ui\BulkActions;
use App\Models\Asset;
use App\Models\Group;
use App\Models\User;
use Tests\TestCase;
@@ -121,4 +121,34 @@ class BulkEditUsersTest extends TestCase
$this->assertEquals('Shelbyville', $admin->fresh()->city);
}
public function test_superuser_can_assign_groups_via_bulk_edit()
{
$group = Group::factory()->create();
$target = User::factory()->create();
$this->actingAs(User::factory()->superuser()->create())
->post(route('users/bulkeditsave'), [
'ids' => [$target->id],
'groups' => [$group->id],
])
->assertRedirect(route('users.index'));
$this->assertTrue($target->fresh()->groups->contains($group));
}
public function test_non_superuser_cannot_assign_groups_via_bulk_edit()
{
$group = Group::factory()->create();
$target = User::factory()->create();
$this->actingAs(User::factory()->editUsers()->create())
->post(route('users/bulkeditsave'), [
'ids' => [$target->id],
'groups' => [$group->id],
])
->assertRedirect(route('users.index'));
$this->assertFalse($target->fresh()->groups->contains($group));
}
}