A free open source IT asset/license management system
Add failing test
Marcus Moore9c1bea00ad89
diff --git a/tests/Feature/ReportTemplates/ReportTemplateTest.php b/tests/Feature/ReportTemplates/ReportTemplateTest.phpindex e234cc7b3e..e1852aebff 100644--- a/tests/Feature/ReportTemplates/ReportTemplateTest.php+++ b/tests/Feature/ReportTemplates/ReportTemplateTest.php@@ -4,6 +4,7 @@ namespace Tests\Feature\ReportTemplates;use App\Models\ReportTemplate;use App\Models\User;+use Illuminate\Database\Eloquent\Collection;use Tests\Support\InteractsWithSettings;use Tests\TestCase;@@ -22,6 +23,24 @@ class ReportTemplateTest extends TestCase}]);}+ public function testSavedTemplatesAreScopedToTheUser()+ {+ // Given there is a saved template for one user+ ReportTemplate::factory()->create(['name' => 'Report A']);++ // When loading reports/custom while acting as another user that also has a saved template+ $user = User::factory()->canViewReports()+ ->has(ReportTemplate::factory(['name' => 'Report B']))+ ->create();++ // The user should not see the other user's template (in view as 'report_templates')+ $this->actingAs($user)+ ->get(route('reports/custom'))+ ->assertViewHas(['report_templates' => function (Collection $reports) {+ return $reports->pluck('name')->doesntContain('Report A');+ }]);+ }+public function testCanLoadASavedReportTemplate(){$user = User::factory()->canViewReports()->create();