feat(blog): allow ROLE_IMPORTER to create drafts and access review queue
This commit is contained in:
@@ -52,6 +52,46 @@ class BlogReviewGateTest extends ApiTestCase
|
||||
$this->assertSame(403, $this->responseCode());
|
||||
}
|
||||
|
||||
public function testReviewQueueIsReadableByImporter(): void
|
||||
{
|
||||
// پنل کرالر با کاربر سیستمیِ ROLE_IMPORTER لاگین میکند؛ بدون این، صف
|
||||
// همیشه «review-queue failed (403)» میداد.
|
||||
$importer = $this->createUser(['ROLE_IMPORTER']);
|
||||
$this->authJson('GET', '/api/v1/admin/blog/review-queue', $importer);
|
||||
$this->assertSame(200, $this->responseCode());
|
||||
}
|
||||
|
||||
// ── who may create a draft ────────────────────────────────────────────────
|
||||
|
||||
public function testImporterCreatesDraftForcedIntoTheReviewGate(): void
|
||||
{
|
||||
$importer = $this->createUser(['ROLE_IMPORTER']);
|
||||
|
||||
$res = $this->authJson('POST', '/api/v1/blog', $importer, [
|
||||
'title' => 'مقاله خط تولید ' . bin2hex(random_bytes(3)),
|
||||
'body' => 'متن آزمایشی مقاله برای تست',
|
||||
'topic_slug' => 'importer-' . bin2hex(random_bytes(4)),
|
||||
// تلاش برای انتشار مستقیم — باید نادیده گرفته شود
|
||||
'status' => Blog::STATUS_PUBLISHED,
|
||||
'review_status' => Blog::REVIEW_APPROVED,
|
||||
]);
|
||||
|
||||
$this->assertSame(201, $this->responseCode());
|
||||
$this->assertSame(Blog::STATUS_DRAFT, $res['data']['data']['status'],
|
||||
'importer must never publish directly');
|
||||
$this->assertSame(Blog::REVIEW_PENDING, $res['data']['data']['review_status'],
|
||||
'importer draft must enter the doctor review gate');
|
||||
}
|
||||
|
||||
public function testPlainUserCannotCreateBlog(): void
|
||||
{
|
||||
$user = $this->createUser(['ROLE_USER']);
|
||||
$this->authJson('POST', '/api/v1/blog', $user, [
|
||||
'title' => 'عنوان', 'body' => 'متن آزمایشی مقاله برای تست',
|
||||
]);
|
||||
$this->assertSame(403, $this->responseCode());
|
||||
}
|
||||
|
||||
// ── approve ───────────────────────────────────────────────────────────────
|
||||
|
||||
public function testApprovePublishesAndRecordsReviewer(): void
|
||||
|
||||
Reference in New Issue
Block a user