From 014c2da915653a64db40e529858279aca902ab61 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 19 Apr 2021 09:53:36 +0200 Subject: [PATCH] Improve wording when editing an user through CLI Signed-off-by: Thomas Citharel --- lib/mix/tasks/mobilizon/users/modify.ex | 6 +++++- lib/mix/tasks/mobilizon/users/show.ex | 7 +++++-- test/tasks/users_test.exs | 22 +++++++++------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/mix/tasks/mobilizon/users/modify.ex b/lib/mix/tasks/mobilizon/users/modify.ex index dd8a4181c..e210e5742 100644 --- a/lib/mix/tasks/mobilizon/users/modify.ex +++ b/lib/mix/tasks/mobilizon/users/modify.ex @@ -58,7 +58,11 @@ defmodule Mix.Tasks.Mobilizon.Users.Modify do An user has been modified with the following information: - email: #{user.email} - Role: #{user.role} - - Activated: #{if user.confirmed_at, do: user.confirmed_at, else: "False"} + - account status: #{ + if user.confirmed_at, + do: "activated on #{DateTime.to_string(user.confirmed_at)} (UTC)", + else: "disabled" + } """) else {:makes_changes, false} -> diff --git a/lib/mix/tasks/mobilizon/users/show.ex b/lib/mix/tasks/mobilizon/users/show.ex index 3c33aaf52..6651eb986 100644 --- a/lib/mix/tasks/mobilizon/users/show.ex +++ b/lib/mix/tasks/mobilizon/users/show.ex @@ -19,8 +19,11 @@ defmodule Mix.Tasks.Mobilizon.Users.Show do actors <- Users.get_actors_for_user(user) do shell_info(""" Informations for the user #{user.email}: - - Activated: #{user.confirmed_at} - - Disabled: #{user.disabled} + - account status: #{ + if user.confirmed_at, + do: "Activated on #{DateTime.to_string(user.confirmed_at)} (UTC)", + else: "disabled" + } - Role: #{user.role} #{display_actors(actors)} """) diff --git a/test/tasks/users_test.exs b/test/tasks/users_test.exs index 4c9cbc625..7cd82946b 100644 --- a/test/tasks/users_test.exs +++ b/test/tasks/users_test.exs @@ -76,16 +76,15 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do describe "show user" do test "show existing user" do - %User{confirmed_at: confirmed_at, role: role, disabled: disabled} = - user = insert(:user, email: @email) + %User{confirmed_at: confirmed_at, role: role} = user = insert(:user, email: @email) actor1 = insert(:actor, user: user) actor2 = insert(:actor, user: user) output = - "Informations for the user #{@email}:\n - Activated: #{confirmed_at}\n - Disabled: #{ - disabled - }\n - Role: #{role}\n Identities (2):\n - @#{actor1.preferred_username} / \n - @#{ + "Informations for the user #{@email}:\n - account status: Activated on #{confirmed_at} (UTC)\n - Role: #{ + role + }\n Identities (2):\n - @#{actor1.preferred_username} / \n - @#{ actor2.preferred_username } / \n\n\n" @@ -139,30 +138,27 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do assert output_received == "An user has been modified with the following information:\n - email: #{ user.email - }\n - Role: #{user.role}\n - Activated: False\n" + }\n - Role: #{user.role}\n - account status: disabled\n" - assert {:ok, %User{email: email, confirmed_at: confirmed_at}} = - Users.get_user_by_email(@email) + assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email) assert is_nil(confirmed_at) Modify.run([@email, "--enable"]) assert_received {:mix_shell, :info, [output_received]} - assert {:ok, %User{email: email, confirmed_at: confirmed_at}} = - Users.get_user_by_email(@email) + assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email) assert output_received == "An user has been modified with the following information:\n - email: #{ user.email - }\n - Role: #{user.role}\n - Activated: #{confirmed_at}\n" + }\n - Role: #{user.role}\n - account status: activated on #{confirmed_at} (UTC)\n" refute is_nil(confirmed_at) Modify.run([@email, "--enable"]) - assert {:ok, %User{email: email, confirmed_at: confirmed_at}} = - Users.get_user_by_email(@email) + assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email) refute is_nil(confirmed_at) assert_received {:mix_shell, :info, [output_received]}