Fixed bug causing editing notification to always show
Updated tests to prevent happening again
Showing
2 changed files
with
8 additions
and
1 deletions
| ... | @@ -498,6 +498,7 @@ class PageRepo extends EntityRepo | ... | @@ -498,6 +498,7 @@ class PageRepo extends EntityRepo |
| 498 | private function activePageEditingQuery(Page $page, $minRange = null) | 498 | private function activePageEditingQuery(Page $page, $minRange = null) |
| 499 | { | 499 | { |
| 500 | $query = $this->pageRevision->where('type', '=', 'update_draft') | 500 | $query = $this->pageRevision->where('type', '=', 'update_draft') |
| 501 | + ->where('page_id', '=', $page->id) | ||
| 501 | ->where('updated_at', '>', $page->updated_at) | 502 | ->where('updated_at', '>', $page->updated_at) |
| 502 | ->where('created_by', '!=', auth()->user()->id) | 503 | ->where('created_by', '!=', auth()->user()->id) |
| 503 | ->with('createdBy'); | 504 | ->with('createdBy'); | ... | ... |
| ... | @@ -48,6 +48,7 @@ class PageDraftTest extends TestCase | ... | @@ -48,6 +48,7 @@ class PageDraftTest extends TestCase |
| 48 | 48 | ||
| 49 | public function test_alert_message_shows_if_someone_else_editing() | 49 | public function test_alert_message_shows_if_someone_else_editing() |
| 50 | { | 50 | { |
| 51 | + $nonEditedPage = \BookStack\Page::take(10)->get()->last(); | ||
| 51 | $addedContent = '<p>test message content</p>'; | 52 | $addedContent = '<p>test message content</p>'; |
| 52 | $this->asAdmin()->visit($this->page->getUrl() . '/edit') | 53 | $this->asAdmin()->visit($this->page->getUrl() . '/edit') |
| 53 | ->dontSeeInField('html', $addedContent); | 54 | ->dontSeeInField('html', $addedContent); |
| ... | @@ -55,8 +56,13 @@ class PageDraftTest extends TestCase | ... | @@ -55,8 +56,13 @@ class PageDraftTest extends TestCase |
| 55 | $newContent = $this->page->html . $addedContent; | 56 | $newContent = $this->page->html . $addedContent; |
| 56 | $newUser = $this->getNewUser(); | 57 | $newUser = $this->getNewUser(); |
| 57 | $this->pageRepo->saveUpdateDraft($this->page, ['html' => $newContent]); | 58 | $this->pageRepo->saveUpdateDraft($this->page, ['html' => $newContent]); |
| 58 | - $this->actingAs($newUser)->visit($this->page->getUrl() . '/edit') | 59 | + |
| 60 | + $this->actingAs($newUser) | ||
| 61 | + ->visit($this->page->getUrl() . '/edit') | ||
| 59 | ->see('Admin has started editing this page'); | 62 | ->see('Admin has started editing this page'); |
| 63 | + $this->flushSession(); | ||
| 64 | + $this->visit($nonEditedPage->getUrl() . '/edit') | ||
| 65 | + ->dontSeeInElement('.notification', 'Admin has started editing this page'); | ||
| 60 | } | 66 | } |
| 61 | 67 | ||
| 62 | public function test_draft_pages_show_on_homepage() | 68 | public function test_draft_pages_show_on_homepage() | ... | ... |
-
Please register or sign in to post a comment