parent
f9fcc9f3c7
commit
08b39500b3
|
@ -158,6 +158,11 @@ class PermissionApplicator
|
||||||
$query->select('id')->from('pages')
|
$query->select('id')->from('pages')
|
||||||
->whereColumn('pages.id', '=', $fullPageIdColumn)
|
->whereColumn('pages.id', '=', $fullPageIdColumn)
|
||||||
->where('pages.draft', '=', false);
|
->where('pages.draft', '=', false);
|
||||||
|
})->orWhereExists(function (QueryBuilder $query) use ($fullPageIdColumn) {
|
||||||
|
$query->select('id')->from('pages')
|
||||||
|
->whereColumn('pages.id', '=', $fullPageIdColumn)
|
||||||
|
->where('pages.draft', '=', true)
|
||||||
|
->where('pages.created_by', '=', $this->currentUser()->id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,6 +184,19 @@ class EntityProvider
|
||||||
return $pageRepo->publishDraft($draftPage, $input);
|
return $pageRepo->publishDraft($draftPage, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and return a new test draft page.
|
||||||
|
*/
|
||||||
|
public function newDraftPage(array $input = ['name' => 'test page', 'html' => 'My new test page']): Page
|
||||||
|
{
|
||||||
|
$book = $this->book();
|
||||||
|
$pageRepo = app(PageRepo::class);
|
||||||
|
$draftPage = $pageRepo->getNewDraftPage($book);
|
||||||
|
$pageRepo->updatePageDraft($draftPage, $input);
|
||||||
|
$this->addToCache($draftPage);
|
||||||
|
return $draftPage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Entity|Entity[] $entities
|
* @param Entity|Entity[] $entities
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -120,6 +120,17 @@ class ImageTest extends TestCase
|
||||||
$this->withHtml($searchFailRequest)->assertElementNotExists('div');
|
$this->withHtml($searchFailRequest)->assertElementNotExists('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_image_gallery_lists_for_draft_page()
|
||||||
|
{
|
||||||
|
$this->actingAs($this->users->editor());
|
||||||
|
$draft = $this->entities->newDraftPage();
|
||||||
|
$this->files->uploadGalleryImageToPage($this, $draft);
|
||||||
|
$image = Image::query()->where('uploaded_to', '=', $draft->id)->firstOrFail();
|
||||||
|
|
||||||
|
$resp = $this->get("/images/gallery?page=1&uploaded_to={$draft->id}");
|
||||||
|
$resp->assertSee($image->getThumb(150, 150));
|
||||||
|
}
|
||||||
|
|
||||||
public function test_image_usage()
|
public function test_image_usage()
|
||||||
{
|
{
|
||||||
$page = $this->entities->page();
|
$page = $this->entities->page();
|
||||||
|
|
Loading…
Reference in New Issue