0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-13 12:21:46 +00:00

- Added more test cases to test the APIs and permission for comments.

This commit is contained in:
Abijeet 2017-06-13 02:31:17 +05:30
parent fd50efb503
commit 7d02f77e67
4 changed files with 264 additions and 2 deletions

View file

@ -77,7 +77,7 @@ $factory->define(BookStack\Comment::class, function($faker) {
$html = '<p>' . $text. '</p>';
return [
'html' => $html,
'text' => '#' . $text,
'text' => $text,
'active' => 1
];
});

View file

@ -17,7 +17,7 @@ class CreateCommentsTable extends Migration
return;
}
Schema::create('comments', function (Blueprint $table) {
$table->increments('id')->unsigned();
$table->increments('id')->unsigned();
$table->integer('page_id')->unsigned();
$table->longText('text')->nullable();
$table->longText('html')->nullable();
@ -45,6 +45,51 @@ class CreateCommentsTable extends Migration
'permission_id' => $permissionId
]);
}
// Get roles with permissions we need to change
/*
$editorRole = DB::table('roles')->where('name', '=', 'editor')->first();
if (!empty($editorRole)) {
$editorRoleId = $editorRole->id;
// Create & attach new entity permissions
$ops = ['Create All', 'Create Own', 'Update Own', 'Delete Own'];
$entity = 'Comment';
foreach ($ops as $op) {
$permissionId = DB::table('role_permissions')->insertGetId([
'name' => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
'display_name' => $op . ' ' . $entity . 's',
'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
]);
DB::table('permission_role')->insert([
'role_id' => $editorRoleId,
'permission_id' => $permissionId
]);
}
}
// Get roles with permissions we need to change
$viewerRole = DB::table('roles')->where('name', '=', 'viewer')->first();
if (!empty($viewerRole)) {
$viewerRoleId = $viewerRole->id;
// Create & attach new entity permissions
$ops = ['Create All'];
$entity = 'Comment';
foreach ($ops as $op) {
$permissionId = DB::table('role_permissions')->insertGetId([
'name' => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
'display_name' => $op . ' ' . $entity . 's',
'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
]);
DB::table('permission_role')->insert([
'role_id' => $viewerRoleId,
'permission_id' => $permissionId
]);
}
}
*/
});
}