Skip to content

Commit

Permalink
Develop (#7)
Browse files Browse the repository at this point in the history
* When the user is an admin, it will not show who their manager is, and before revoking managers, we need to revoke admin privileges.

* fix FakeControllerTest.php
user id can be not 1

* fix UserFactory.php for apostrophe tests

---------

Co-authored-by: Artem Otliaguzov <Artem.Otliaguzov@cesnet.cz>
  • Loading branch information
temaotl and temaotl authored Feb 29, 2024
1 parent bf1dbdb commit ec6f21b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class UserFactory extends Factory
public function definition(): array
{
return [
'name' => fake()->firstName().' '.fake()->lastName(),
'name' => fake()->firstName().' '.str_replace("'", '', fake()->lastName()),
'uniqueid' => $id = fake()->unique()->safeEmail(),
'email' => $id,
'emails' => random_int(0, 1) ? "$id;".fake()->safeEmail() : null,
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/user-status.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class="dark:bg-indigo-800 dark:text-indigo-100 px-2 ml-2 text-xs font-semibold t
</span>
@endif

@if ($model->manager)
@if ($model->manager && !$model->admin)
<span
class="dark:bg-indigo-800 dark:text-indigo-100 px-2 ml-2 text-xs font-semibold text-indigo-800 bg-indigo-100 rounded-full">
{{ __('common.manager') }}
Expand Down
3 changes: 2 additions & 1 deletion resources/views/users/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
'users.partials.status')

@includeWhen(request()->user()->can('do-everything') &&
!request()->user()->is($user),
!request()->user()->is($user) &&
!$user->admin,
'users.partials.subrole')

@includeWhen(request()->user()->can('do-everything') &&
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Http/Controllers/FakeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function a_user_can_log_in_using_fakecontroller(): void
$this
->followingRedirects()
->from('/')
->post(route('fakelogin'), ['id' => 1])
->post(route('fakelogin'), ['id' => $user->id])
->assertOk();

$user->refresh();
Expand Down

0 comments on commit ec6f21b

Please sign in to comment.