From 2b3a0f19b9b414ced2e789902b5d5b8d334e49ec Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 3 Nov 2021 08:50:28 +0100 Subject: [PATCH] Fix backend tests Signed-off-by: Thomas Citharel --- lib/service/actor_suspension.ex | 4 ++-- lib/service/workers/activity_builder.ex | 2 +- test/graphql/resolvers/comment_test.exs | 4 ++-- test/graphql/resolvers/discussion_test.exs | 4 ++-- test/graphql/resolvers/event_test.exs | 8 ++++---- test/graphql/resolvers/member_test.exs | 6 +++--- test/service/notifier/email_test.exs | 2 +- test/service/notifier/push_test.exs | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/service/actor_suspension.ex b/lib/service/actor_suspension.ex index 17d3b7492..838070259 100644 --- a/lib/service/actor_suspension.ex +++ b/lib/service/actor_suspension.ex @@ -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} diff --git a/lib/service/workers/activity_builder.ex b/lib/service/workers/activity_builder.ex index 0dcc2a238..c8caee878 100644 --- a/lib/service/workers/activity_builder.ex +++ b/lib/service/workers/activity_builder.ex @@ -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: [] diff --git a/test/graphql/resolvers/comment_test.exs b/test/graphql/resolvers/comment_test.exs index 9a26d766c..265b2c374 100644 --- a/test/graphql/resolvers/comment_test.exs +++ b/test/graphql/resolvers/comment_test.exs @@ -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 diff --git a/test/graphql/resolvers/discussion_test.exs b/test/graphql/resolvers/discussion_test.exs index 5b5b2cece..8b90ae9a4 100644 --- a/test/graphql/resolvers/discussion_test.exs +++ b/test/graphql/resolvers/discussion_test.exs @@ -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 diff --git a/test/graphql/resolvers/event_test.exs b/test/graphql/resolvers/event_test.exs index 0f5489b70..9badb50e8 100644 --- a/test/graphql/resolvers/event_test.exs +++ b/test/graphql/resolvers/event_test.exs @@ -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 diff --git a/test/graphql/resolvers/member_test.exs b/test/graphql/resolvers/member_test.exs index db2a42f08..80ec3f545 100644 --- a/test/graphql/resolvers/member_test.exs +++ b/test/graphql/resolvers/member_test.exs @@ -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 = diff --git a/test/service/notifier/email_test.exs b/test/service/notifier/email_test.exs index 07045a0f0..6e841db0b 100644 --- a/test/service/notifier/email_test.exs +++ b/test/service/notifier/email_test.exs @@ -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} diff --git a/test/service/notifier/push_test.exs b/test/service/notifier/push_test.exs index ff2c6a08d..0bb198052 100644 --- a/test/service/notifier/push_test.exs +++ b/test/service/notifier/push_test.exs @@ -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}