fix admin can't add private texture
This commit is contained in:
parent
8a07597265
commit
97705755c5
|
|
@ -100,7 +100,7 @@ class ClosetController extends Controller
|
|||
return json(trans('user.closet.add.not-found'), 1);
|
||||
}
|
||||
|
||||
if (!$texture->public && $texture->uploader != $user->uid) {
|
||||
if (!$texture->public && ($texture->uploader != $user->uid && !$user->isAdmin())) {
|
||||
return json(trans('skinlib.show.private'), 1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,3 +19,5 @@ $factory->define(Texture::class, function (Faker\Generator $faker) {
|
|||
$factory->state(Texture::class, 'alex', ['type' => 'alex']);
|
||||
|
||||
$factory->state(Texture::class, 'cape', ['type' => 'cape']);
|
||||
|
||||
$factory->state(Texture::class, 'private', ['public' => false]);
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@
|
|||
- Fixed that the same texture files with different models were treated as different textures.
|
||||
- Fixed when uploading duplicated texture, alert is missing.
|
||||
- Fixed that "score cost per closet item" isn't calculated at "texture upload" page.
|
||||
- Fixed that administrator can't add private texture to his/her closet.
|
||||
|
||||
## Removed
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@
|
|||
- 修复同一材质文件但模型不同被认为不同材质的问题
|
||||
- 修复上传重复材质时没有提示用户的问题
|
||||
- 「材质上传」页面的积分消耗没有计算衣柜收藏所需的积分
|
||||
- 修复管理员不能添加私有材质到衣柜的问题
|
||||
|
||||
## 移除
|
||||
|
||||
|
|
|
|||
|
|
@ -142,14 +142,28 @@ class ClosetControllerTest extends TestCase
|
|||
'message' => trans('skinlib.show.private'),
|
||||
]);
|
||||
|
||||
// Add a texture successfully
|
||||
$this->postJson(
|
||||
'/user/closet/add',
|
||||
['tid' => $texture->tid, 'name' => $name]
|
||||
)->assertJson([
|
||||
'code' => 0,
|
||||
'message' => trans('user.closet.add.success', ['name' => $name]),
|
||||
// Administrator can add it.
|
||||
$privateTexture = factory(Texture::class)->state('private')->create([
|
||||
'uploader' => 0,
|
||||
]);
|
||||
$this->actingAs(factory(User::class)->state('admin')->create())
|
||||
->postJson(
|
||||
'/user/closet/add',
|
||||
['tid' => $privateTexture->tid, 'name' => $name]
|
||||
)->assertJson([
|
||||
'code' => 0,
|
||||
'message' => trans('user.closet.add.success', ['name' => $name]),
|
||||
]);
|
||||
|
||||
// Add a texture successfully
|
||||
$this->actingAs($this->user)
|
||||
->postJson(
|
||||
'/user/closet/add',
|
||||
['tid' => $texture->tid, 'name' => $name]
|
||||
)->assertJson([
|
||||
'code' => 0,
|
||||
'message' => trans('user.closet.add.success', ['name' => $name]),
|
||||
]);
|
||||
$this->assertEquals($likes + 1, Texture::find($texture->tid)->likes);
|
||||
$this->user = User::find($this->user->uid);
|
||||
$this->assertEquals(90, $this->user->score);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user