From 13fa1080dc08fa0bc175e799a9f49cdd6e3a7e3a Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sun, 18 Oct 2015 16:06:06 +0100 Subject: [PATCH] Added tests for user crud --- resources/assets/sass/styles.scss | 5 ++++ resources/views/users/edit.blade.php | 2 +- resources/views/users/index.blade.php | 4 +-- tests/AuthTest.php | 41 +++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/resources/assets/sass/styles.scss b/resources/assets/sass/styles.scss index d652fbedc..da08ba457 100644 --- a/resources/assets/sass/styles.scss +++ b/resources/assets/sass/styles.scss @@ -30,6 +30,11 @@ body.dragging, body.dragging * { // User Avatar Images .avatar { border-radius: 100%; + background-color: #EEE; + &.med { + width: 40px; + height: 40px; + } } // System wide notifications diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php index 2c3c6079f..5e28059fe 100644 --- a/resources/views/users/edit.blade.php +++ b/resources/views/users/edit.blade.php @@ -9,7 +9,7 @@
diff --git a/resources/views/users/index.blade.php b/resources/views/users/index.blade.php index 49e124e56..6df242f10 100644 --- a/resources/views/users/index.blade.php +++ b/resources/views/users/index.blade.php @@ -10,7 +10,7 @@

Users

@if($currentUser->can('user-create'))

- Add New User + Add new user

@endif @@ -22,7 +22,7 @@ @foreach($users as $user) - +
{{$user->name}}{{$user->name}} @if($currentUser->can('user-update') || $currentUser->id == $user->id) diff --git a/tests/AuthTest.php b/tests/AuthTest.php index 1c5628d9c..befa0214d 100644 --- a/tests/AuthTest.php +++ b/tests/AuthTest.php @@ -102,6 +102,47 @@ class AuthTest extends TestCase ->seeInDatabase('users', ['name' => $user->name, 'email' => $user->email, 'email_confirmed' => true]); } + public function testUserControl() + { + $user = factory(\BookStack\User::class)->make(); + // Test creation + $this->asAdmin() + ->visit('/users') + ->click('Add new user') + ->type($user->name, '#name') + ->type($user->email, '#email') + ->select(2, '#role') + ->type($user->password, '#password') + ->type($user->password, '#password-confirm') + ->press('Save') + ->seeInDatabase('users', $user->toArray()) + ->seePageIs('/users') + ->see($user->name); + $user = $user->where('email', '=', $user->email)->first(); + + // Test editing + $this->asAdmin() + ->visit('/users') + ->click($user->name) + ->seePageIs('/users/' . $user->id) + ->see($user->email) + ->type('Barry Scott', '#name') + ->press('Save') + ->seePageIs('/users') + ->seeInDatabase('users', ['id' => $user->id, 'name' => 'Barry Scott']) + ->notSeeInDatabase('users', ['name' => $user->name]); + $user = $user->find($user->id); + + // Test Deletion + $this->asAdmin() + ->visit('/users/' . $user->id) + ->click('Delete user') + ->see($user->name) + ->press('Confirm') + ->seePageIs('/users') + ->notSeeInDatabase('users', ['name' => $user->name]); + } + public function testLogout() { $this->asAdmin()