A free open source IT asset/license management system
Added one more test for source reflection permission
snipe958d88783f78
diff --git a/tests/Feature/CalendarEvents/CalendarEventsPageTest.php b/tests/Feature/CalendarEvents/CalendarEventsPageTest.phpindex 068f71a314..53e54f9b60 100644--- a/tests/Feature/CalendarEvents/CalendarEventsPageTest.php+++ b/tests/Feature/CalendarEvents/CalendarEventsPageTest.php@@ -5,6 +5,15 @@ namespace Tests\Feature\CalendarEvents;use App\Models\User;use Tests\TestCase;+/**+ * Coverage for the calendar page's controller-level gate. The web+ * controller's base check is "can the viewer view AT LEAST ONE of+ * the HasCalendarEvents source models" (Asset, License, User,+ * Maintenance) rather than a hardcoded view-Asset. That means a+ * license-only or user-only admin should be able to render the+ * calendar page shell and get their relevant events via the+ * companion API. These tests lock that behavior down.+ */class CalendarEventsPageTest extends TestCase{public function test_page_renders()@@ -20,4 +29,29 @@ class CalendarEventsPageTest extends TestCase->get(route('calendar.index'))->assertForbidden();}++ public function test_asset_only_viewer_can_render_the_page()+ {+ $this->actingAs(User::factory()->viewAssets()->create())+ ->get(route('calendar.index'))+ ->assertOk();+ }++ public function test_license_only_viewer_can_render_the_page()+ {+ // A user whose only calendar-relevant permission is view+ // Licenses should still land on the page shell. Per-row+ // filtering in the API endpoint drops the non-license events+ // downstream; the page-level gate should not lock them out.+ $this->actingAs(User::factory()->viewLicenses()->create())+ ->get(route('calendar.index'))+ ->assertOk();+ }++ public function test_user_only_viewer_can_render_the_page()+ {+ $this->actingAs(User::factory()->viewUsers()->create())+ ->get(route('calendar.index'))+ ->assertOk();+ }}