Mock :crypt.crypt/2 because otherwise the test fails on Mac OS
authorSergey Suprunenko <suprunenko.s@gmail.com>
Fri, 5 Apr 2019 20:40:30 +0000 (22:40 +0200)
committerSergey Suprunenko <suprunenko.s@gmail.com>
Fri, 5 Apr 2019 20:48:11 +0000 (22:48 +0200)
test/plugs/legacy_authentication_plug_test.exs

index 302662797230a9ca3e40bed80f5ba0f10f5c12c7..8b0b06772a6273dce9e75781ce3f7e92f3b28e27 100644 (file)
@@ -47,16 +47,18 @@ defmodule Pleroma.Plugs.LegacyAuthenticationPlugTest do
       |> assign(:auth_user, user)
 
     conn =
-      with_mock User,
-        reset_password: fn user, %{password: password, password_confirmation: password} ->
-          send(self(), :reset_password)
-          {:ok, user}
-        end do
-        conn
-        |> LegacyAuthenticationPlug.call(%{})
+      with_mocks([
+        {:crypt, [], [crypt: fn _password, password_hash -> password_hash end]},
+        {User, [],
+         [
+           reset_password: fn user, %{password: password, password_confirmation: password} ->
+             {:ok, user}
+           end
+         ]}
+      ]) do
+        LegacyAuthenticationPlug.call(conn, %{})
       end
 
-    assert_received :reset_password
     assert conn.assigns.user == user
   end