forked from potsda.mn/mobilizon
Fix backend tests
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
f44e466194
commit
2b3a0f19b9
|
@ -211,7 +211,7 @@ defmodule Mobilizon.Service.ActorSuspension do
|
|||
end
|
||||
|
||||
@spec reset_default_actor_id(Actor.t()) :: {:ok, User.t() | nil} | {:error, :user_not_found}
|
||||
defp reset_default_actor_id(%Actor{type: :Person, user: %User{id: user_id} = user, id: actor_id}) do
|
||||
defp reset_default_actor_id(%Actor{type: :Person, user: %User{} = user, id: actor_id}) do
|
||||
Logger.debug("reset_default_actor_id")
|
||||
|
||||
new_actor =
|
||||
|
@ -219,7 +219,7 @@ defmodule Mobilizon.Service.ActorSuspension do
|
|||
|> Users.get_actors_for_user()
|
||||
|> Enum.find(&(&1.id !== actor_id))
|
||||
|
||||
{:ok, Users.update_user_default_actor(user_id, new_actor)}
|
||||
{:ok, Users.update_user_default_actor(user, new_actor)}
|
||||
rescue
|
||||
_e in Ecto.NoResultsError ->
|
||||
{:error, :user_not_found}
|
||||
|
|
|
@ -52,7 +52,7 @@ defmodule Mobilizon.Service.Workers.ActivityBuilder do
|
|||
|> Enum.map(& &1.user_id)
|
||||
|> Enum.filter(& &1)
|
||||
|> Enum.uniq()
|
||||
|> Enum.map(&Users.get_user_with_settings!/1)
|
||||
|> Enum.map(&Users.get_user_with_activity_settings!/1)
|
||||
end
|
||||
|
||||
defp users_to_notify(_), do: []
|
||||
|
|
|
@ -170,7 +170,7 @@ defmodule Mobilizon.GraphQL.Resolvers.CommentTest do
|
|||
|
||||
# Change the current actor for user
|
||||
actor2 = insert(:actor, user: user)
|
||||
Mobilizon.Users.update_user_default_actor(user.id, actor2)
|
||||
Mobilizon.Users.update_user_default_actor(user, actor2)
|
||||
|
||||
res =
|
||||
conn
|
||||
|
@ -183,7 +183,7 @@ defmodule Mobilizon.GraphQL.Resolvers.CommentTest do
|
|||
assert hd(res["errors"])["message"] ==
|
||||
"You cannot delete this comment"
|
||||
|
||||
Mobilizon.Users.update_user_default_actor(user.id, actor)
|
||||
Mobilizon.Users.update_user_default_actor(user, actor)
|
||||
|
||||
res =
|
||||
conn
|
||||
|
|
|
@ -448,7 +448,7 @@ defmodule Mobilizon.GraphQL.Resolvers.DiscussionTest do
|
|||
|
||||
# # Change the current actor for user
|
||||
# actor2 = insert(:actor, user: user)
|
||||
# Mobilizon.Users.update_user_default_actor(user.id, actor2)
|
||||
# Mobilizon.Users.update_user_default_actor(user, actor2)
|
||||
|
||||
# res =
|
||||
# conn
|
||||
|
@ -461,7 +461,7 @@ defmodule Mobilizon.GraphQL.Resolvers.DiscussionTest do
|
|||
# assert hd(res["errors"])["message"] ==
|
||||
# "You cannot delete this comment"
|
||||
|
||||
# Mobilizon.Users.update_user_default_actor(user.id, actor)
|
||||
# Mobilizon.Users.update_user_default_actor(user, actor)
|
||||
|
||||
# res =
|
||||
# conn
|
||||
|
|
|
@ -1237,7 +1237,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
|||
|> Map.put(:attributed_to_id, "#{group_id}")
|
||||
|> Map.put(:eventId, to_string(event.id))
|
||||
|
||||
Users.update_user_default_actor(user.id, member_not_approved_actor)
|
||||
Users.update_user_default_actor(user, member_not_approved_actor)
|
||||
|
||||
res =
|
||||
conn
|
||||
|
@ -1252,7 +1252,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
|||
assert hd(res["errors"])["message"] ==
|
||||
"This profile doesn't have permission to update an event on behalf of this group"
|
||||
|
||||
Users.update_user_default_actor(user.id, not_member_actor)
|
||||
Users.update_user_default_actor(user, not_member_actor)
|
||||
|
||||
res =
|
||||
conn
|
||||
|
@ -1267,7 +1267,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
|||
assert hd(res["errors"])["message"] ==
|
||||
"This profile doesn't have permission to update an event on behalf of this group"
|
||||
|
||||
Users.update_user_default_actor(user.id, member_actor)
|
||||
Users.update_user_default_actor(user, member_actor)
|
||||
|
||||
res =
|
||||
conn
|
||||
|
@ -1282,7 +1282,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
|||
assert hd(res["errors"])["message"] ==
|
||||
"This profile doesn't have permission to update an event on behalf of this group"
|
||||
|
||||
Users.update_user_default_actor(user.id, moderator_actor)
|
||||
Users.update_user_default_actor(user, moderator_actor)
|
||||
|
||||
res =
|
||||
conn
|
||||
|
|
|
@ -423,7 +423,7 @@ defmodule Mobilizon.GraphQL.Resolvers.MemberTest do
|
|||
} do
|
||||
user = insert(:user)
|
||||
actor = insert(:actor, user: user)
|
||||
Mobilizon.Users.update_user_default_actor(user.id, actor)
|
||||
Mobilizon.Users.update_user_default_actor(user, actor)
|
||||
|
||||
%Member{id: member_id} =
|
||||
insert(:member, %{actor: target_actor, parent: group, role: :member})
|
||||
|
@ -449,7 +449,7 @@ defmodule Mobilizon.GraphQL.Resolvers.MemberTest do
|
|||
group: group,
|
||||
target_actor: target_actor
|
||||
} do
|
||||
Mobilizon.Users.update_user_default_actor(user.id, actor)
|
||||
Mobilizon.Users.update_user_default_actor(user, actor)
|
||||
insert(:member, actor: actor, parent: group, role: :administrator)
|
||||
|
||||
%Member{id: member_id} =
|
||||
|
@ -504,7 +504,7 @@ defmodule Mobilizon.GraphQL.Resolvers.MemberTest do
|
|||
actor: actor,
|
||||
group: group
|
||||
} do
|
||||
Mobilizon.Users.update_user_default_actor(user.id, actor)
|
||||
Mobilizon.Users.update_user_default_actor(user, actor)
|
||||
%Member{id: member_id} = insert(:member, actor: actor, parent: group, role: :administrator)
|
||||
|
||||
res =
|
||||
|
|
|
@ -29,7 +29,7 @@ defmodule Mobilizon.Service.Notifier.EmailTest do
|
|||
describe "sending email for activities" do
|
||||
test "when the user doesn't allow it" do
|
||||
%Activity{} = activity = insert(:mobilizon_activity, inserted_at: DateTime.utc_now())
|
||||
%User{} = user = insert(:user)
|
||||
%User{} = user = insert(:user, activity_settings: [])
|
||||
%Setting{} = user_settings = insert(:settings, user_id: user.id, group_notifications: :none)
|
||||
user = %User{user | settings: user_settings}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ defmodule Mobilizon.Service.Notifier.PushTest do
|
|||
describe "sending push notification for activities" do
|
||||
test "when the user doesn't allow it" do
|
||||
%Activity{} = activity = insert(:mobilizon_activity, inserted_at: DateTime.utc_now())
|
||||
%User{} = user = insert(:user)
|
||||
%User{} = user = insert(:user, activity_settings: [])
|
||||
%Setting{} = user_settings = insert(:settings, user_id: user.id)
|
||||
user = %User{user | settings: user_settings}
|
||||
|
||||
|
|
Loading…
Reference in a new issue