Skip to content

Commit

Permalink
notes and some playing around, push for eod
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerrlongg committed May 1, 2024
1 parent 6a7f3ec commit e177993
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/Http/Controllers/Assets/BulkAssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public function edit(Request $request)
*/
public function update(Request $request)
{
//dd($request->all());
$this->authorize('update', Asset::class);
$has_errors = 0;
$error_array = array();
Expand Down
1 change: 1 addition & 0 deletions database/factories/CustomFieldsetFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function hasMultipleCustomFields(array $fields = null): self
{
return $this->afterCreating(function (CustomFieldset $fieldset) {
if (empty($fields)) {
//why are there two after creating and why does it break if i remove one
return $this->afterCreating(function (CustomFieldset $fieldset) {
$mac_address = CustomField::factory()->macAddress()->create();
$ram = CustomField::factory()->ram()->create();
Expand Down
10 changes: 5 additions & 5 deletions tests/Feature/Assets/AssetsBulkEditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ public function testBulkEditAssetsAcceptsAndUpdatesUnencryptedCustomFields()
$ram = CustomField::factory()->ram()->create();
$cpu = CustomField::factory()->cpu()->create();

$assets = Asset::factory()->laptopMbp()->count(10)->hasMultipleCustomFields([$mac_address, $ram, $cpu])->create([
$assets = Asset::factory()->count(10)->hasMultipleCustomFields([$mac_address, $ram, $cpu])->create([
$ram->db_column => 8,
$cpu->db_column => '2.1',
]);

$id_array = $assets->pluck('id')->toArray();
// seems like the fieldset is random, so bulkedit isn't working because assets don't have the "correct" fieldset
// look into more tomorrow
dd(Asset::find(1)->model->fieldset);

// submits the ids and new values for each attribute
$asset = Asset::find(1);
$id_array = $assets->pluck('id')->toArray();

$this->assertEquals(8, $asset->{$ram->db_column});
$this->actingAs(User::factory()->editAssets()->create())->post(route('hardware/bulksave'), [
'ids' => $id_array,
$ram->db_column => 16,
Expand Down

0 comments on commit e177993

Please sign in to comment.