mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-11 16:14:18 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
74a5bcd490
|
@ -554,7 +554,7 @@ class Helper
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($selection != null){
|
if ($selection != null){
|
||||||
return $category_types[$selection];
|
return $category_types[strtolower($selection)];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return $category_types;
|
return $category_types;
|
||||||
|
|
|
@ -25,4 +25,62 @@ class UsersSearchTest extends TestCase
|
||||||
$this->assertTrue($results->pluck('name')->contains(fn($text) => str_contains($text, 'Luke')));
|
$this->assertTrue($results->pluck('name')->contains(fn($text) => str_contains($text, 'Luke')));
|
||||||
$this->assertFalse($results->pluck('name')->contains(fn($text) => str_contains($text, 'Darth')));
|
$this->assertFalse($results->pluck('name')->contains(fn($text) => str_contains($text, 'Darth')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testResultsWhenSearchingForActiveUsers()
|
||||||
|
{
|
||||||
|
User::factory()->create(['first_name' => 'Active', 'last_name' => 'User']);
|
||||||
|
User::factory()->create(['first_name' => 'Deleted', 'last_name' => 'User'])->delete();
|
||||||
|
|
||||||
|
$response = $this->actingAsForApi(User::factory()->viewUsers()->create())
|
||||||
|
->getJson(route('api.users.index', [
|
||||||
|
'deleted' => 'false',
|
||||||
|
'company_id' => '',
|
||||||
|
'search' => 'user',
|
||||||
|
'order' => 'asc',
|
||||||
|
'offset' => '0',
|
||||||
|
'limit' => '20',
|
||||||
|
]))
|
||||||
|
->assertOk();
|
||||||
|
|
||||||
|
$firstNames = collect($response->json('rows'))->pluck('first_name');
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
$firstNames->contains('Active'),
|
||||||
|
'Expected user does not appear in results'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertFalse(
|
||||||
|
$firstNames->contains('Deleted'),
|
||||||
|
'Unexpected deleted user appears in results'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testResultsWhenSearchingForDeletedUsers()
|
||||||
|
{
|
||||||
|
User::factory()->create(['first_name' => 'Active', 'last_name' => 'User']);
|
||||||
|
User::factory()->create(['first_name' => 'Deleted', 'last_name' => 'User'])->delete();
|
||||||
|
|
||||||
|
$response = $this->actingAsForApi(User::factory()->viewUsers()->create())
|
||||||
|
->getJson(route('api.users.index', [
|
||||||
|
'deleted' => 'true',
|
||||||
|
'company_id' => '',
|
||||||
|
'search' => 'user',
|
||||||
|
'order' => 'asc',
|
||||||
|
'offset' => '0',
|
||||||
|
'limit' => '20',
|
||||||
|
]))
|
||||||
|
->assertOk();
|
||||||
|
|
||||||
|
$firstNames = collect($response->json('rows'))->pluck('first_name');
|
||||||
|
|
||||||
|
$this->assertFalse(
|
||||||
|
$firstNames->contains('Active'),
|
||||||
|
'Unexpected active user appears in results'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
$firstNames->contains('Deleted'),
|
||||||
|
'Expected deleted user does not appear in results'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue