Merge branch 'fix-editing-user-email' into 'master'
Fix CLI to change an user's email and add a test See merge request framasoft/mobilizon!899
This commit is contained in:
commit
a986d5e084
|
@ -40,7 +40,7 @@ defmodule Mix.Tasks.Mobilizon.Users.Modify do
|
|||
with {:ok, %User{} = user} <- Users.get_user_by_email(email),
|
||||
attrs <- %{},
|
||||
role <- calculate_role(admin?, moderator?, user?),
|
||||
attrs <- process_new_value(attrs, :mail, new_email, user.email),
|
||||
attrs <- process_new_value(attrs, :email, new_email, user.email),
|
||||
attrs <- process_new_value(attrs, :role, role, user.role),
|
||||
attrs <-
|
||||
if(disable? && !is_nil(user.confirmed_at),
|
||||
|
|
|
@ -170,5 +170,22 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do
|
|||
assert_received {:mix_shell, :error, [message]}
|
||||
assert message =~ "Can't use both --enabled and --disable options at the same time."
|
||||
end
|
||||
|
||||
@modified_email "modified@email.tld"
|
||||
|
||||
test "change user's email" do
|
||||
user = insert(:user, email: @email)
|
||||
Modify.run([@email, "--email", @modified_email])
|
||||
|
||||
assert_received {:mix_shell, :info, [output_received]}
|
||||
|
||||
assert {:ok, %User{confirmed_at: confirmed_at, email: @modified_email}} =
|
||||
Users.get_user_by_email(@modified_email)
|
||||
|
||||
assert output_received ==
|
||||
"An user has been modified with the following information:\n - email: #{
|
||||
@modified_email
|
||||
}\n - Role: #{user.role}\n - account status: activated on #{confirmed_at} (UTC)\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue