X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Ftasks%2Fuser_test.exs;h=1f97740be3701cf52e9de47c5abee8037a3546c4;hb=c0b7bc2927cb7d4826fe2c992a90c571a06e94c1;hp=242265da5c48b68a75bd212d4e8ab65a446cd588;hpb=627e5a0a4992cc19fc65a7e93a09c470c8e2bf33;p=akkoma diff --git a/test/tasks/user_test.exs b/test/tasks/user_test.exs index 242265da5..1f97740be 100644 --- a/test/tasks/user_test.exs +++ b/test/tasks/user_test.exs @@ -50,7 +50,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do assert_received {:mix_shell, :info, [message]} assert message =~ "created" - user = User.get_by_nickname(unsaved.nickname) + user = User.get_cached_by_nickname(unsaved.nickname) assert user.name == unsaved.name assert user.email == unsaved.email assert user.bio == unsaved.bio @@ -75,7 +75,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do assert_received {:mix_shell, :info, [message]} assert message =~ "will not be created" - refute User.get_by_nickname(unsaved.nickname) + refute User.get_cached_by_nickname(unsaved.nickname) end end @@ -88,7 +88,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do assert_received {:mix_shell, :info, [message]} assert message =~ " deleted" - user = User.get_by_nickname(user.nickname) + user = User.get_cached_by_nickname(user.nickname) assert user.info.deactivated end @@ -109,7 +109,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do assert_received {:mix_shell, :info, [message]} assert message =~ " deactivated" - user = User.get_by_nickname(user.nickname) + user = User.get_cached_by_nickname(user.nickname) assert user.info.deactivated end @@ -121,7 +121,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do assert_received {:mix_shell, :info, [message]} assert message =~ " activated" - user = User.get_by_nickname(user.nickname) + user = User.get_cached_by_nickname(user.nickname) refute user.info.deactivated end @@ -150,7 +150,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do assert_received {:mix_shell, :info, [message]} assert message =~ "Successfully unsubscribed" - user = User.get_by_nickname(user.nickname) + user = User.get_cached_by_nickname(user.nickname) assert Enum.empty?(user.following) assert user.info.deactivated end @@ -178,7 +178,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do assert_received {:mix_shell, :info, [message]} assert message =~ ~r/Admin status .* true/ - user = User.get_by_nickname(user.nickname) + user = User.get_cached_by_nickname(user.nickname) assert user.info.is_moderator assert user.info.locked assert user.info.is_admin @@ -204,7 +204,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do assert_received {:mix_shell, :info, [message]} assert message =~ ~r/Admin status .* false/ - user = User.get_by_nickname(user.nickname) + user = User.get_cached_by_nickname(user.nickname) refute user.info.is_moderator refute user.info.locked refute user.info.is_admin @@ -338,4 +338,31 @@ defmodule Mix.Tasks.Pleroma.UserTest do assert message == "User #{nickname} statuses deleted." end end + + describe "running toggle_confirmed" do + test "user is confirmed" do + %{id: id, nickname: nickname} = insert(:user, info: %{confirmation_pending: false}) + + assert :ok = Mix.Tasks.Pleroma.User.run(["toggle_confirmed", nickname]) + assert_received {:mix_shell, :info, [message]} + assert message == "#{nickname} needs confirmation." + + user = Repo.get(User, id) + assert user.info.confirmation_pending + assert user.info.confirmation_token + end + + test "user is not confirmed" do + %{id: id, nickname: nickname} = + insert(:user, info: %{confirmation_pending: true, confirmation_token: "some token"}) + + assert :ok = Mix.Tasks.Pleroma.User.run(["toggle_confirmed", nickname]) + assert_received {:mix_shell, :info, [message]} + assert message == "#{nickname} doesn't need confirmation." + + user = Repo.get(User, id) + refute user.info.confirmation_pending + refute user.info.confirmation_token + end + end end