Improve wording when editing an user through CLI

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-04-19 09:53:36 +02:00
parent 489787ceb5
commit 014c2da915
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
3 changed files with 19 additions and 16 deletions

View file

@ -58,7 +58,11 @@ defmodule Mix.Tasks.Mobilizon.Users.Modify do
An user has been modified with the following information: An user has been modified with the following information:
- email: #{user.email} - email: #{user.email}
- Role: #{user.role} - 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 else
{:makes_changes, false} -> {:makes_changes, false} ->

View file

@ -19,8 +19,11 @@ defmodule Mix.Tasks.Mobilizon.Users.Show do
actors <- Users.get_actors_for_user(user) do actors <- Users.get_actors_for_user(user) do
shell_info(""" shell_info("""
Informations for the user #{user.email}: Informations for the user #{user.email}:
- Activated: #{user.confirmed_at} - account status: #{
- Disabled: #{user.disabled} if user.confirmed_at,
do: "Activated on #{DateTime.to_string(user.confirmed_at)} (UTC)",
else: "disabled"
}
- Role: #{user.role} - Role: #{user.role}
#{display_actors(actors)} #{display_actors(actors)}
""") """)

View file

@ -76,16 +76,15 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do
describe "show user" do describe "show user" do
test "show existing user" do test "show existing user" do
%User{confirmed_at: confirmed_at, role: role, disabled: disabled} = %User{confirmed_at: confirmed_at, role: role} = user = insert(:user, email: @email)
user = insert(:user, email: @email)
actor1 = insert(:actor, user: user) actor1 = insert(:actor, user: user)
actor2 = insert(:actor, user: user) actor2 = insert(:actor, user: user)
output = output =
"Informations for the user #{@email}:\n - Activated: #{confirmed_at}\n - Disabled: #{ "Informations for the user #{@email}:\n - account status: Activated on #{confirmed_at} (UTC)\n - Role: #{
disabled role
}\n - Role: #{role}\n Identities (2):\n - @#{actor1.preferred_username} / \n - @#{ }\n Identities (2):\n - @#{actor1.preferred_username} / \n - @#{
actor2.preferred_username actor2.preferred_username
} / \n\n\n" } / \n\n\n"
@ -139,30 +138,27 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do
assert output_received == assert output_received ==
"An user has been modified with the following information:\n - email: #{ "An user has been modified with the following information:\n - email: #{
user.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}} = assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email)
Users.get_user_by_email(@email)
assert is_nil(confirmed_at) assert is_nil(confirmed_at)
Modify.run([@email, "--enable"]) Modify.run([@email, "--enable"])
assert_received {:mix_shell, :info, [output_received]} assert_received {:mix_shell, :info, [output_received]}
assert {:ok, %User{email: email, confirmed_at: confirmed_at}} = assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email)
Users.get_user_by_email(@email)
assert output_received == assert output_received ==
"An user has been modified with the following information:\n - email: #{ "An user has been modified with the following information:\n - email: #{
user.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) refute is_nil(confirmed_at)
Modify.run([@email, "--enable"]) Modify.run([@email, "--enable"])
assert {:ok, %User{email: email, confirmed_at: confirmed_at}} = assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email)
Users.get_user_by_email(@email)
refute is_nil(confirmed_at) refute is_nil(confirmed_at)
assert_received {:mix_shell, :info, [output_received]} assert_received {:mix_shell, :info, [output_received]}