mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Added test for models with same name but no model number
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
3ae4a5caf0
commit
e96b9b2f4f
|
@ -79,4 +79,25 @@ class CreateAssetModelsTest extends TestCase
|
|||
|
||||
}
|
||||
|
||||
public function testUniquenessAcrossModelNameAndModelNumberWithBlankModelNumber()
|
||||
{
|
||||
AssetModel::factory()->create(['name' => 'Test Model']);
|
||||
|
||||
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->postJson(route('api.models.store'), [
|
||||
'name' => 'Test Model',
|
||||
])
|
||||
->assertStatus(200)
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('error')
|
||||
->assertJson([
|
||||
'messages' => [
|
||||
'name' => ['The name must be unique across models and model number. '],
|
||||
'model_number' => ['The model number must be unique across models and name. '],
|
||||
],
|
||||
])
|
||||
->json();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,7 +65,27 @@ class CreateAssetModelsTest extends TestCase
|
|||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasErrors(['name','model_number'])
|
||||
->assertRedirect(route('models.create'))
|
||||
->assertInvalid(['name','model_number']);
|
||||
|
||||
$this->followRedirects($response)->assertSee(trans('general.error'));
|
||||
|
||||
}
|
||||
|
||||
public function testUniquenessAcrossModelNameAndModelNumberWithoutModelNumber()
|
||||
{
|
||||
|
||||
AssetModel::factory()->create(['name' => 'Test Model', 'model_number'=> null]);
|
||||
|
||||
$response = $this->actingAs(User::factory()->superuser()->create())
|
||||
->from(route('models.create'))
|
||||
->post(route('models.store'), [
|
||||
'name' => 'Test Model',
|
||||
'model_number' => null,
|
||||
'category_id' => Category::factory()->create()->id
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasErrors(['name','model_number'])
|
||||
->assertRedirect(route('models.create'))
|
||||
->assertInvalid(['name','model_number']);
|
||||
|
||||
|
|
Loading…
Reference in a new issue