]> BookStack Code Mirror - bookstack/blobdiff - tests/Activity/WatchTest.php
Notifications: Fixed send content permission checking
[bookstack] / tests / Activity / WatchTest.php
index e8cb3cbd8b104567eb66354776173412c557eda2..00f3f5e4db51b9fa90b598fd2d6df3d730edb43f 100644 (file)
@@ -312,4 +312,21 @@ class WatchTest extends TestCase
                 && str_contains($mailContent, 'Created By: ' . $admin->name);
         });
     }
+
+    public function test_notifications_not_sent_if_lacking_view_permission_for_related_item()
+    {
+        $notifications = Notification::fake();
+        $editor = $this->users->editor();
+        $page = $this->entities->page();
+
+        $watches = new UserEntityWatchOptions($editor, $page);
+        $watches->updateWatchLevel('comments');
+        $this->permissions->disableEntityInheritedPermissions($page);
+
+        $this->asAdmin()->post("/comment/{$page->id}", [
+            'text' => 'My new comment response',
+        ])->assertOk();
+
+        $notifications->assertNothingSentTo($editor);
+    }
 }