Improve wording when editing an user through CLI
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
489787ceb5
commit
014c2da915
|
@ -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} ->
|
||||
|
|
|
@ -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)}
|
||||
""")
|
||||
|
|
|
@ -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]}
|
||||
|
|
Loading…
Reference in a new issue