mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Update slack_endpoint to webhook_endpoint in test and notification
This commit is contained in:
parent
f6d0dd0f93
commit
9c4a3ce56a
|
@ -41,8 +41,8 @@ class CheckoutableListener
|
|||
if (! $event->checkedOutTo instanceof User) {
|
||||
|
||||
// @todo: comment
|
||||
if (Setting::getSettings() && Setting::getSettings()->slack_endpoint) {
|
||||
Notification::route('slack', Setting::getSettings()->slack_endpoint)
|
||||
if (Setting::getSettings() && Setting::getSettings()->webhook_endpoint) {
|
||||
Notification::route('slack', Setting::getSettings()->webhook_endpoint)
|
||||
->notify(new CheckoutAssetNotification(
|
||||
$event->checkoutable,
|
||||
$event->checkedOutTo,
|
||||
|
|
|
@ -53,7 +53,7 @@ class CheckoutAssetNotification extends Notification
|
|||
{
|
||||
$notifyBy = [];
|
||||
|
||||
if ((Setting::getSettings()) && (Setting::getSettings()->slack_endpoint != '')) {
|
||||
if ((Setting::getSettings()) && (Setting::getSettings()->webhook_endpoint != '')) {
|
||||
\Log::debug('use slack');
|
||||
$notifyBy[] = 'slack';
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
namespace Tests\Feature\Notifications;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Category;
|
||||
use App\Models\Location;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
|
@ -15,23 +13,15 @@ use Tests\TestCase;
|
|||
|
||||
class AssetCheckoutSlackNotificationTest extends TestCase
|
||||
{
|
||||
private Category $assetLaptopCategory;
|
||||
private string $slackWebhookUrl = 'https://hooks.slack.com/services/NZ59O2F54K/Q4465WNLM8/672N8MU5JV15RP436WDHRN58';
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->assetLaptopCategory = Category::factory()->assetLaptopCategory();
|
||||
}
|
||||
|
||||
public function testNotificationSentToSlackWhenAssetCheckedOutToUserAndSlackNotificationEnabled()
|
||||
{
|
||||
Notification::fake();
|
||||
|
||||
Setting::factory()->create(['slack_endpoint' => $this->slackWebhookUrl]);
|
||||
Setting::factory()->create(['webhook_endpoint' => $this->slackWebhookUrl]);
|
||||
|
||||
$asset = $this->createAsset();
|
||||
$asset = Asset::factory()->laptopMbp()->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$asset->checkOut(
|
||||
|
@ -52,11 +42,11 @@ class AssetCheckoutSlackNotificationTest extends TestCase
|
|||
{
|
||||
Notification::fake();
|
||||
|
||||
Setting::factory()->create(['slack_endpoint' => $this->slackWebhookUrl]);
|
||||
Setting::factory()->create(['webhook_endpoint' => $this->slackWebhookUrl]);
|
||||
|
||||
$assetBeingCheckedOut = $this->createAsset();
|
||||
$assetBeingCheckedOut = Asset::factory()->laptopMbp()->create();
|
||||
$assetBeingCheckedOut->checkOut(
|
||||
$this->createAsset(),
|
||||
Asset::factory()->laptopMbp()->create(),
|
||||
User::factory()->superuser()->create()->id
|
||||
);
|
||||
|
||||
|
@ -75,9 +65,9 @@ class AssetCheckoutSlackNotificationTest extends TestCase
|
|||
{
|
||||
Notification::fake();
|
||||
|
||||
$assetBeingCheckedOut = $this->createAsset();
|
||||
$assetBeingCheckedOut = Asset::factory()->laptopMbp()->create();
|
||||
$assetBeingCheckedOut->checkOut(
|
||||
$this->createAsset(),
|
||||
Asset::factory()->laptopMbp()->create(),
|
||||
User::factory()->superuser()->create()->id
|
||||
);
|
||||
|
||||
|
@ -91,9 +81,9 @@ class AssetCheckoutSlackNotificationTest extends TestCase
|
|||
{
|
||||
Notification::fake();
|
||||
|
||||
Setting::factory()->create(['slack_endpoint' => $this->slackWebhookUrl]);
|
||||
Setting::factory()->create(['webhook_endpoint' => $this->slackWebhookUrl]);
|
||||
|
||||
$asset = $this->createAsset();
|
||||
$asset = Asset::factory()->laptopMbp()->create();
|
||||
$asset->checkOut(
|
||||
Location::factory()->create(),
|
||||
User::factory()->superuser()->create()->id
|
||||
|
@ -114,7 +104,7 @@ class AssetCheckoutSlackNotificationTest extends TestCase
|
|||
{
|
||||
Notification::fake();
|
||||
|
||||
$asset = $this->createAsset();
|
||||
$asset = Asset::factory()->laptopMbp()->create();
|
||||
$asset->checkOut(
|
||||
Location::factory()->create(),
|
||||
User::factory()->superuser()->create()->id
|
||||
|
@ -125,13 +115,4 @@ class AssetCheckoutSlackNotificationTest extends TestCase
|
|||
CheckoutAssetNotification::class,
|
||||
);
|
||||
}
|
||||
|
||||
private function createAsset()
|
||||
{
|
||||
return Asset::factory()->create([
|
||||
'model_id' => AssetModel::factory()->create([
|
||||
'category_id' => $this->assetLaptopCategory->id,
|
||||
])->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue