Introduce group basic federation, event new page and notifications

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-02-18 08:57:00 +01:00
parent 300ef8f245
commit 4144e9ffd0
416 changed files with 32220 additions and 16750 deletions

View File

@@ -4,8 +4,9 @@ defmodule Mobilizon.EventsTest do
import Mobilizon.Factory
alias Mobilizon.Actors.Actor
alias Mobilizon.Events
alias Mobilizon.Events.{Comment, Event, Participant, Session, Tag, TagRelation, Track}
alias Mobilizon.{Conversations, Events}
alias Mobilizon.Conversations.Comment
alias Mobilizon.Events.{Event, Participant, Session, Tag, TagRelation, Track}
alias Mobilizon.Service.Workers
alias Mobilizon.Storage.Page
@@ -530,65 +531,4 @@ defmodule Mobilizon.EventsTest do
assert_raise Ecto.NoResultsError, fn -> Events.get_track!(track.id) end
end
end
describe "comments" do
@valid_attrs %{text: "some text"}
@update_attrs %{text: "some updated text"}
@invalid_attrs %{text: nil, url: nil}
test "list_comments/0 returns all comments" do
%Comment{id: comment_id} = insert(:comment)
comment_ids = Events.list_comments() |> Enum.map(& &1.id)
assert comment_ids == [comment_id]
end
test "get_comment!/1 returns the comment with given id" do
%Comment{id: comment_id} = insert(:comment)
comment_fetched = Events.get_comment!(comment_id)
assert comment_fetched.id == comment_id
end
test "create_comment/1 with valid data creates a comment" do
actor = insert(:actor)
comment_data = Map.merge(@valid_attrs, %{actor_id: actor.id})
case Events.create_comment(comment_data) do
{:ok, %Comment{} = comment} ->
assert comment.text == "some text"
assert comment.actor_id == actor.id
err ->
flunk("Failed to create a comment #{inspect(err)}")
end
end
test "create_comment/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Events.create_comment(@invalid_attrs)
end
test "update_comment/2 with valid data updates the comment" do
comment = insert(:comment)
case Events.update_comment(comment, @update_attrs) do
{:ok, %Comment{} = comment} ->
assert comment.text == "some updated text"
err ->
flunk("Failed to update a comment #{inspect(err)}")
end
end
test "update_comment/2 with invalid data returns error changeset" do
comment = insert(:comment)
assert {:error, %Ecto.Changeset{}} = Events.update_comment(comment, @invalid_attrs)
comment_fetched = Events.get_comment!(comment.id)
assert comment = comment_fetched
end
test "delete_comment/1 deletes the comment" do
comment = insert(:comment)
assert {:ok, %Comment{}} = Events.delete_comment(comment)
refute is_nil(Events.get_comment!(comment.id).deleted_at)
end
end
end