Merge branch 'improve-tests' into 'master'

Improve tests

See merge request framasoft/mobilizon!78
This commit is contained in:
Thomas Citharel
2019-02-22 18:13:01 +01:00
7 changed files with 131 additions and 26 deletions

View File

@@ -21,8 +21,4 @@ defmodule Mobilizon.Actors.Follower do
|> validate_required([:score, :approved, :target_actor_id, :actor_id])
|> unique_constraint(:target_actor_id, name: :followers_actor_target_actor_unique_index)
end
def url(%Follower{id: id}) do
"#{MobilizonWeb.Endpoint.url()}/follow/#{id}/activity"
end
end

View File

@@ -6,17 +6,6 @@ defmodule MobilizonWeb.Resolvers.Person do
alias Mobilizon.Actors.{Actor, User}
alias Mobilizon.Service.ActivityPub
@deprecated "Use find_person/3 or find_group/3 instead"
def find_actor(_parent, %{preferred_username: name}, _resolution) do
case ActivityPub.find_or_make_actor_from_nickname(name) do
{:ok, actor} ->
{:ok, actor}
_ ->
{:error, "Actor with name #{name} not found"}
end
end
@doc """
Find a person
"""
@@ -65,6 +54,13 @@ defmodule MobilizonWeb.Resolvers.Person do
end
end
@doc """
This function is used to create more identities from an existing user
"""
def create_person(_parent, _args, _resolution) do
{:error, "You need to be logged-in to create a new identity"}
end
@doc """
This function is used to register a person afterwards the user has been created (but not activated)
"""

View File

@@ -19,15 +19,15 @@ defmodule MobilizonWeb.Resolvers.Tag do
{:ok, Mobilizon.Events.list_tags_for_event(id)}
end
@doc """
Retrieve the list of related tags for a given tag ID
"""
def get_related_tags(_parent, %{tag_id: tag_id}, _resolution) do
with %Tag{} = tag <- Mobilizon.Events.get_tag!(tag_id),
tags <- Mobilizon.Events.tag_neighbors(tag) do
{:ok, tags}
end
end
# @doc """
# Retrieve the list of related tags for a given tag ID
# """
# def get_related_tags(_parent, %{tag_id: tag_id}, _resolution) do
# with %Tag{} = tag <- Mobilizon.Events.get_tag!(tag_id),
# tags <- Mobilizon.Events.tag_neighbors(tag) do
# {:ok, tags}
# end
# end
@doc """
Retrieve the list of related tags for a parent tag

View File

@@ -131,6 +131,7 @@ defmodule MobilizonWeb.Schema do
import_fields(:event_queries)
import_fields(:participant_queries)
import_fields(:category_queries)
import_fields(:tag_queries)
end
@desc """

View File

@@ -246,8 +246,9 @@ defmodule Mobilizon.Service.ActivityPub do
Make an actor follow another
"""
def follow(%Actor{} = follower, %Actor{} = followed, activity_id \\ nil, local \\ true) do
with {:ok, %Follower{} = follow} <- Actor.follow(followed, follower, true),
activity_follow_id <- activity_id || Follower.url(follow),
with {:ok, %Follower{id: follow_id}} <- Actor.follow(followed, follower, true),
activity_follow_id <-
activity_id || "#{MobilizonWeb.Endpoint.url()}/follow/#{follow_id}/activity",
data <- make_follow_data(followed, follower, activity_follow_id),
{:ok, activity} <- insert(data, local),
:ok <- maybe_federate(activity) do