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