Add tests for the bulk confirm/unconfirm tasks
authorMark Felder <feld@FreeBSD.org>
Wed, 9 Sep 2020 14:02:07 +0000 (09:02 -0500)
committerMark Felder <feld@FreeBSD.org>
Wed, 9 Sep 2020 14:02:07 +0000 (09:02 -0500)
test/tasks/user_test.exs

index ef77fdc9c038a1bf64d6614dc46a2ca8f323ccbf..b8c423c48455590765345bbc15faac0d68c441f7 100644 (file)
@@ -571,4 +571,44 @@ defmodule Mix.Tasks.Pleroma.UserTest do
       assert message =~ "Could not change user tags"
     end
   end
+
+  describe "bulk confirm and unconfirm" do
+    test "confirm all" do
+      user1 = insert(:user, confirmation_pending: true)
+      user2 = insert(:user, confirmation_pending: true)
+
+      assert user1.confirmation_pending
+      assert user2.confirmation_pending
+
+      Mix.Tasks.Pleroma.User.run(["confirm_all"])
+
+      user1 = User.get_cached_by_nickname(user1.nickname)
+      user2 = User.get_cached_by_nickname(user2.nickname)
+
+      refute user1.confirmation_pending
+      refute user2.confirmation_pending
+    end
+
+    test "unconfirm all" do
+      user1 = insert(:user, confirmation_pending: false)
+      user2 = insert(:user, confirmation_pending: false)
+      admin = insert(:user, is_admin: true, confirmation_pending: false)
+      mod = insert(:user, is_moderator: true, confirmation_pending: false)
+
+      refute user1.confirmation_pending
+      refute user2.confirmation_pending
+
+      Mix.Tasks.Pleroma.User.run(["unconfirm_all"])
+
+      user1 = User.get_cached_by_nickname(user1.nickname)
+      user2 = User.get_cached_by_nickname(user2.nickname)
+      admin = User.get_cached_by_nickname(admin.nickname)
+      mod = User.get_cached_by_nickname(mod.nickname)
+
+      assert user1.confirmation_pending
+      assert user2.confirmation_pending
+      refute admin.confirmation_pending
+      refute mod.confirmation_pending
+    end
+  end
 end