]> BookStack Code Mirror - bookstack/commitdiff
Fixed bug causing editing notification to always show
authorDan Brown <redacted>
Sun, 13 Mar 2016 14:33:43 +0000 (14:33 +0000)
committerDan Brown <redacted>
Sun, 13 Mar 2016 14:33:43 +0000 (14:33 +0000)
Updated tests to prevent happening again

app/Repos/PageRepo.php
tests/Entity/PageDraftTest.php

index 547f3e4a68bc665337f007dc2069ccfd60982abb..4c3512fa79ab67da996c619b2ebe3a5ea120ec10 100644 (file)
@@ -498,6 +498,7 @@ class PageRepo extends EntityRepo
     private function activePageEditingQuery(Page $page, $minRange = null)
     {
         $query = $this->pageRevision->where('type', '=', 'update_draft')
+            ->where('page_id', '=', $page->id)
             ->where('updated_at', '>', $page->updated_at)
             ->where('created_by', '!=', auth()->user()->id)
             ->with('createdBy');
index 218b458bd4bb171bc59d3dc60529221946db75a5..2c9a288140574e088aaecd3bcf09555c79ac4023 100644 (file)
@@ -48,6 +48,7 @@ class PageDraftTest extends TestCase
 
     public function test_alert_message_shows_if_someone_else_editing()
     {
+        $nonEditedPage = \BookStack\Page::take(10)->get()->last();
         $addedContent = '<p>test message content</p>';
         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
             ->dontSeeInField('html', $addedContent);
@@ -55,8 +56,13 @@ class PageDraftTest extends TestCase
         $newContent = $this->page->html . $addedContent;
         $newUser = $this->getNewUser();
         $this->pageRepo->saveUpdateDraft($this->page, ['html' => $newContent]);
-        $this->actingAs($newUser)->visit($this->page->getUrl() . '/edit')
+
+        $this->actingAs($newUser)
+            ->visit($this->page->getUrl() . '/edit')
             ->see('Admin has started editing this page');
+            $this->flushSession();
+        $this->visit($nonEditedPage->getUrl() . '/edit')
+            ->dontSeeInElement('.notification', 'Admin has started editing this page');
     }
 
     public function test_draft_pages_show_on_homepage()