Skip to content

A free open source IT asset/license management system

Handle accessories

Marcus Moore6f99381d1301
diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php
index 062cadab4f..5a90f30632 100644
--- a/app/Listeners/CheckoutableListener.php
+++ b/app/Listeners/CheckoutableListener.php
@@ -237,7 +237,7 @@ class CheckoutableListener
$acceptance->assignedTo()->associate($event->checkedOutTo);
// @todo: adjust for other categories
- if (data_get($event, 'checkoutable.model.category.alert_on_response')) {
+ if (data_get($event, 'checkoutable.model.category.alert_on_response') || data_get($event, 'checkoutable.category.alert_on_response')) {
$acceptance->alert_on_response_id = auth()->id();
}
diff --git a/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php b/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php
index 2435d1c01d..0e6ce8d3d0 100644
--- a/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php
+++ b/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php
@@ -47,7 +47,26 @@ class SettingAlertOnResponseTest extends TestCase
public function test_does_not_set_alert_on_response_if_disabled_by_category_for_accessory()
{
- $this->markTestIncomplete();
+ $accessory = Accessory::factory()->create();
+ $accessory->category->update([
+ 'require_acceptance' => true,
+ 'alert_on_response' => false,
+ ]);
+
+ $this->actingAs($this->actor)
+ ->post(route('accessories.checkout.store', $accessory), [
+ 'checkout_to_type' => 'user',
+ 'status_id' => (string) Statuslabel::factory()->readyToDeploy()->create()->id,
+ 'assigned_user' => $this->assignedUser->id,
+ 'checkout_qty' => 1,
+ ]);
+
+ $this->assertDatabaseHas('checkout_acceptances', [
+ 'checkoutable_type' => Accessory::class,
+ 'checkoutable_id' => $accessory->id,
+ 'assigned_to_id' => $this->assignedUser->id,
+ 'alert_on_response_id' => null,
+ ]);
}
public function test_sets_alert_on_response_if_enabled_by_category_for_asset()