Fixed bug causing editing notification to always show

Updated tests to prevent happening again
This commit is contained in:
Dan Brown 2016-03-13 14:33:43 +00:00
parent a06321675a
commit 4656c12f6d
2 changed files with 8 additions and 1 deletions

View 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');

View 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()