mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Implement deleted log
This commit is contained in:
parent
59e6874a4a
commit
0cc3031864
|
@ -72,6 +72,16 @@ class ReportTemplate extends Model
|
||||||
$logAction->log_meta = json_encode($changed);
|
$logAction->log_meta = json_encode($changed);
|
||||||
$logAction->logaction('update');
|
$logAction->logaction('update');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static::deleted(function (ReportTemplate $reportTemplate) {
|
||||||
|
$logAction = new Actionlog([
|
||||||
|
'item_type' => ReportTemplate::class,
|
||||||
|
'item_id' => $reportTemplate->id,
|
||||||
|
'created_by' => auth()->id(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$logAction->logaction('delete');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -144,7 +144,30 @@ class ReportTemplateActivityLoggingTest extends TestCase
|
||||||
|
|
||||||
public function testDeletingReportTemplateIsLogged()
|
public function testDeletingReportTemplateIsLogged()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$user = User::factory()->create();
|
||||||
|
[$reportTemplateA, $reportTemplateB] = ReportTemplate::factory()->count(2)->create();
|
||||||
|
|
||||||
|
$reportTemplateA->delete();
|
||||||
|
$this->actingAs($user);
|
||||||
|
$reportTemplateB->delete();
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('action_logs', [
|
||||||
|
'created_by' => null,
|
||||||
|
'action_type' => 'delete',
|
||||||
|
'target_id' => null,
|
||||||
|
'target_type' => null,
|
||||||
|
'item_type' => ReportTemplate::class,
|
||||||
|
'item_id' => $reportTemplateA->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('action_logs', [
|
||||||
|
'created_by' => $user->id,
|
||||||
|
'action_type' => 'delete',
|
||||||
|
'target_id' => null,
|
||||||
|
'target_type' => null,
|
||||||
|
'item_type' => ReportTemplate::class,
|
||||||
|
'item_id' => $reportTemplateB->id,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLogEntryForDeletingReportTemplateCanBeDisplayedCorrectly()
|
public function testLogEntryForDeletingReportTemplateCanBeDisplayedCorrectly()
|
||||||
|
|
Loading…
Reference in a new issue