mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
tests a little broken, added some nullchecks
This commit is contained in:
parent
8684a3efc3
commit
9b80843c77
|
@ -24,7 +24,7 @@ trait MayContainCustomFields
|
|||
});
|
||||
// if there are custom fields, find the one's that don't exist on the model's fieldset and add an error to the validator's error bag
|
||||
if (count($request_fields) > 0) {
|
||||
$request_fields->diff($asset_model->fieldset->fields->pluck('db_column'))
|
||||
$request_fields->diff($asset_model?->fieldset?->fields?->pluck('db_column'))
|
||||
->each(function ($request_field_name) use ($request_fields, $validator) {
|
||||
if (CustomField::where('db_column', $request_field_name)->exists()) {
|
||||
$validator->errors()->add($request_field_name, trans('validation.custom.custom_field_not_found_on_model'));
|
||||
|
|
|
@ -269,6 +269,8 @@ class UpdateAssetTest extends TestCase
|
|||
{
|
||||
$this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL');
|
||||
|
||||
// hmm, for some reason this customfield isn't attached to a fieldset
|
||||
// need to check out these factory methods...
|
||||
$field = CustomField::factory()->testEncrypted()->create();
|
||||
$asset = Asset::factory()->hasEncryptedCustomField($field)->create();
|
||||
$superuser = User::factory()->superuser()->create();
|
||||
|
|
Loading…
Reference in a new issue