Skip to content

Commit 44dd061

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 7603a93 + 2ff47ed commit 44dd061

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

app/Console/Commands/SendAcceptanceReminder.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function handle()
6464
->groupBy(function($item) {
6565
return $item['acceptance']->assignedTo ? $item['acceptance']->assignedTo->id : '';
6666
});
67+
$no_email_list= [];
6768

6869
foreach($unacceptedAssetGroups as $unacceptedAssetGroup) {
6970
// The [0] is weird, but it allows for the item_count to work and grabs the appropriate info for each user.
@@ -72,7 +73,10 @@ public function handle()
7273
$locale = $acceptance->assignedTo?->locale;
7374
$email = $acceptance->assignedTo?->email;
7475
if(!$email){
75-
$this->info($acceptance->assignedTo?->present()->fullName().' has no email address.');
76+
$no_email_list[] = [
77+
'id' => $acceptance->assignedTo->id,
78+
'name' => $acceptance->assignedTo->present()->fullName(),
79+
];
7680
}
7781
$item_count = $unacceptedAssetGroup->count();
7882

@@ -86,6 +90,14 @@ public function handle()
8690
}
8791

8892
$this->info($count.' users notified.');
93+
$headers = ['ID', 'Name'];
94+
$rows = [];
95+
96+
foreach ($no_email_list as $user) {
97+
$rows[] = [$user['id'], $user['name']];
98+
}
99+
$this->info("The following users do not have an email address:");
100+
$this->table($headers, $rows);
89101

90102
return 0;
91103
}

app/Http/Controllers/Assets/BulkAssetsController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,19 @@ public function update(Request $request) : RedirectResponse
358358
* to someone/something.
359359
*/
360360
if ($request->filled('status_id')) {
361-
$updated_status = Statuslabel::find($request->input('status_id'));
361+
try {
362+
$updated_status = Statuslabel::findOrFail($request->input('status_id'));
363+
} catch (ModelNotFoundException $e) {
364+
return redirect($bulk_back_url)->with('error', trans('admin/statuslabels/message.does_not_exist'));
365+
}
362366

363367
// We cannot assign a non-deployable status type if the asset is already assigned.
364368
// This could probably be added to a form request.
365369
// If the asset isn't assigned, we don't care what the status is.
366370
// Otherwise we need to make sure the status type is still a deployable one.
367371
if (
368372
($asset->assigned_to == '')
369-
|| ($updated_status->deployable == '1') && ($asset->assetstatus->deployable == '1')
373+
|| ($updated_status->deployable == '1') && ($asset->assetstatus?->deployable == '1')
370374
) {
371375
$this->update_array['status_id'] = $updated_status->id;
372376
}

tests/Feature/Console/SendAcceptanceReminderTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ public function testAcceptanceReminderCommandHandlesUserWithoutEmail()
4343
CheckoutAcceptance::factory()->pending()->create([
4444
'assigned_to_id' => $userA->id,
4545
]);
46-
46+
$headers = ['ID', 'Name'];
47+
$rows = [
48+
[$userA->id, $userA->present()->fullName()],
49+
];
4750
$this->artisan('snipeit:acceptance-reminder')
48-
->expectsOutput($userA->present()->fullName().' has no email address.')
51+
->expectsOutput("The following users do not have an email address:")
52+
->expectsTable($headers, $rows)
4953
->assertExitCode(0);
5054

5155
Mail::assertNotSent(UnacceptedAssetReminderMail::class);

0 commit comments

Comments
 (0)