Commit dab7089d authored by Mariusz Fik's avatar Mariusz Fik

Fix creation of an activated user.

Signed-off-by: 's avatarMariusz Fik <mariusz@fidano.pl>
parent 5ae06f6d
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
</el-form-item> </el-form-item>
<el-form-item :label="trans('users.form.is activated')" <el-form-item :label="trans('users.form.is activated')"
:class="{'el-form-item is-error': form.errors.has('activated') }"> :class="{'el-form-item is-error': form.errors.has('activated') }">
<el-checkbox v-model="user.activated">Activated</el-checkbox> <el-checkbox v-model="user.is_activated">Activated</el-checkbox>
<div class="el-form-item__error" v-if="form.errors.has('activated')" <div class="el-form-item__error" v-if="form.errors.has('activated')"
v-text="form.errors.first('activated')"></div> v-text="form.errors.first('activated')"></div>
</el-form-item> </el-form-item>
...@@ -161,6 +161,7 @@ ...@@ -161,6 +161,7 @@
permissions: {}, permissions: {},
roles: {}, roles: {},
is_new: false, is_new: false,
is_activated: false,
}, },
roles: {}, roles: {},
form: new Form(), form: new Form(),
......
<?php
namespace Modules\User\Tests;
use Modules\User\Entities\Sentinel\User;
use Modules\User\Http\Controllers\Api\UserController;
use Modules\User\Http\Requests\CreateUserRequest;
use Modules\User\Permissions\PermissionManager;
use Modules\User\Repositories\UserRepository;
use Modules\User\Repositories\UserTokenRepository;
class ApiUserControllerTest extends BaseUserTestCase
{
/**
* @var UserRepository
*/
private $user;
/**
* @var PermissionManager
*/
private $permissions;
/**
* @var UserTokenRepository
*/
private $userToken;
public function setUp()
{
parent::setUp();
$this->user = app(UserRepository::class);
$this->permissions = app(PermissionManager::class);
$this->userToken = app(UserTokenRepository::class);
}
/** @test */
public function it_creates_a_new_activated_user()
{
$data = [
'email' => 'user@domain.tld',
'password' => 'Pa$$w0rd',
'is_activated' => true,
];
$request = CreateUserRequest::create('', '', $data);
$controller = new UserController($this->user, $this->permissions, $this->userToken);
$controller->store($request);
$user = $this->user->find(1);
$this->assertInstanceOf(User::class, $user);
$this->assertTrue($user->isActivated());
}
}
...@@ -17,7 +17,7 @@ class FullUserTransformer extends Resource ...@@ -17,7 +17,7 @@ class FullUserTransformer extends Resource
'first_name' => $this->first_name, 'first_name' => $this->first_name,
'last_name' => $this->last_name, 'last_name' => $this->last_name,
'email' => $this->email, 'email' => $this->email,
'activated' => $this->isActivated(), 'is_activated' => $this->isActivated(),
'last_login' => $this->last_login, 'last_login' => $this->last_login,
'created_at' => $this->created_at, 'created_at' => $this->created_at,
'permissions' => $permissions, 'permissions' => $permissions,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment