Allow tag relations + bump ecto deps
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
9
test/fixtures/mastodon-delete.json
vendored
9
test/fixtures/mastodon-delete.json
vendored
@@ -2,12 +2,9 @@
|
||||
"type": "Delete",
|
||||
"signature": {
|
||||
"type": "RsaSignature2017",
|
||||
"signatureValue": "cw0RlfNREf+5VdsOYcCBDrv521eiLsDTAYNHKffjF0bozhCnOh+wHkFik7WamUk$
|
||||
uEiN4L2H6vPlGRprAZGRhEwgy+A7rIFQNmLrpW5qV5UNVI/2F7kngEHqZQgbQYj9hW+5GMYmPkHdv3D72ZefGw$
|
||||
4Xa2NBLGFpAjQllfzt7kzZLKKY2DM99FdUa64I2Wj3iD04Hs23SbrUdAeuGk/c1Cg6bwGNG4vxoiwn1jikgJLA$
|
||||
NAlSGjsRGdR7LfbC7GqWWsW3cSNsLFPoU6FyALjgTrrYoHiXe0QHggw+L3yMLfzB2S/L46/VRbyb+WDKMBIXUL$
|
||||
5owmzHSi6e/ZtCI3w==",
|
||||
"creator": "http://mastodon.example.org/users/gargron#main-key", "created": "2018-03-03T16:24:11Z"
|
||||
"signatureValue": "cw0RlfNREf+5VdsOYcCBDrv521eiLsDTAYNHKffjF0bozhCnOh+wHkFik7WamUkuEiN4L2H6vPlGRprAZGRhEwgy+A7rIFQNmLrpW5qV5UNVI/2F7kngEHqZQgbQYj9hW+5GMYmPkHdv3D72ZefGw4Xa2NBLGFpAjQllfzt7kzZLKKY2DM99FdUa64I2Wj3iD04Hs23SbrUdAeuGk/c1Cg6bwGNG4vxoiwn1jikgJLANAlSGjsRGdR7LfbC7GqWWsW3cSNsLFPoU6FyALjgTrrYoHiXe0QHggw+L3yMLfzB2S/L46/VRbyb+WDKMBIXUL5owmzHSi6e/ZtCI3w==",
|
||||
"creator": "http://mastodon.example.org/users/gargron#main-key",
|
||||
"created": "2018-03-03T16:24:11Z"
|
||||
},
|
||||
"object": {
|
||||
"type": "Tombstone",
|
||||
|
||||
@@ -373,7 +373,7 @@ defmodule Mobilizon.ActorsTest do
|
||||
assert {:error, :user_not_found} = Actors.get_user_by_email(@email, true)
|
||||
|
||||
Actors.update_user(user, %{
|
||||
"confirmed_at" => DateTime.utc_now(),
|
||||
"confirmed_at" => DateTime.utc_now() |> DateTime.truncate(:second),
|
||||
"confirmation_sent_at" => nil,
|
||||
"confirmation_token" => nil
|
||||
})
|
||||
|
||||
@@ -6,9 +6,9 @@ defmodule Mobilizon.EventsTest do
|
||||
alias Mobilizon.Events
|
||||
|
||||
@event_valid_attrs %{
|
||||
begins_on: "2010-04-17 14:00:00.000000Z",
|
||||
begins_on: "2010-04-17 14:00:00Z",
|
||||
description: "some description",
|
||||
ends_on: "2010-04-17 14:00:00.000000Z",
|
||||
ends_on: "2010-04-17 14:00:00Z",
|
||||
title: "some title",
|
||||
url: "some url",
|
||||
uuid: "b5126423-f1af-43e4-a923-002a03003ba4"
|
||||
@@ -24,15 +24,15 @@ defmodule Mobilizon.EventsTest do
|
||||
end
|
||||
|
||||
@valid_attrs %{
|
||||
begins_on: "2010-04-17 14:00:00.000000Z",
|
||||
begins_on: "2010-04-17 14:00:00Z",
|
||||
description: "some description",
|
||||
ends_on: "2010-04-17 14:00:00.000000Z",
|
||||
ends_on: "2010-04-17 14:00:00Z",
|
||||
title: "some title"
|
||||
}
|
||||
@update_attrs %{
|
||||
begins_on: "2011-05-18 15:01:01.000000Z",
|
||||
begins_on: "2011-05-18 15:01:01Z",
|
||||
description: "some updated description",
|
||||
ends_on: "2011-05-18 15:01:01.000000Z",
|
||||
ends_on: "2011-05-18 15:01:01Z",
|
||||
title: "some updated title"
|
||||
}
|
||||
@invalid_attrs %{begins_on: nil, description: nil, ends_on: nil, title: nil}
|
||||
@@ -90,9 +90,9 @@ defmodule Mobilizon.EventsTest do
|
||||
|> Map.put(:address_id, address.id)
|
||||
|
||||
with {:ok, %Event{} = event} <- Events.create_event(valid_attrs) do
|
||||
assert event.begins_on == DateTime.from_naive!(~N[2010-04-17 14:00:00.000000Z], "Etc/UTC")
|
||||
assert event.begins_on == DateTime.from_naive!(~N[2010-04-17 14:00:00Z], "Etc/UTC")
|
||||
assert event.description == "some description"
|
||||
assert event.ends_on == DateTime.from_naive!(~N[2010-04-17 14:00:00.000000Z], "Etc/UTC")
|
||||
assert event.ends_on == DateTime.from_naive!(~N[2010-04-17 14:00:00Z], "Etc/UTC")
|
||||
assert event.title == "some title"
|
||||
else
|
||||
err ->
|
||||
@@ -107,9 +107,9 @@ defmodule Mobilizon.EventsTest do
|
||||
test "update_event/2 with valid data updates the event", %{event: event} do
|
||||
assert {:ok, event} = Events.update_event(event, @update_attrs)
|
||||
assert %Event{} = event
|
||||
assert event.begins_on == DateTime.from_naive!(~N[2011-05-18 15:01:01.000000Z], "Etc/UTC")
|
||||
assert event.begins_on == DateTime.from_naive!(~N[2011-05-18 15:01:01Z], "Etc/UTC")
|
||||
assert event.description == "some updated description"
|
||||
assert event.ends_on == DateTime.from_naive!(~N[2011-05-18 15:01:01.000000Z], "Etc/UTC")
|
||||
assert event.ends_on == DateTime.from_naive!(~N[2011-05-18 15:01:01Z], "Etc/UTC")
|
||||
assert event.title == "some updated title"
|
||||
end
|
||||
|
||||
@@ -302,6 +302,81 @@ defmodule Mobilizon.EventsTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "tags_relations" do
|
||||
alias Mobilizon.Events.TagRelation
|
||||
alias Mobilizon.Events.Tag
|
||||
|
||||
setup do
|
||||
tag1 = insert(:tag)
|
||||
tag2 = insert(:tag)
|
||||
{:ok, tag1: tag1, tag2: tag2}
|
||||
end
|
||||
|
||||
test "create_tag_relation/1 with valid data creates a tag relation", %{
|
||||
tag1: %Tag{id: tag1_id} = tag1,
|
||||
tag2: %Tag{id: tag2_id} = tag2
|
||||
} do
|
||||
assert {:ok, %TagRelation{} = tag_relation} =
|
||||
Events.create_tag_relation(%{tag_id: tag1_id, link_id: tag2_id})
|
||||
|
||||
assert Events.are_tags_linked(tag1, tag2)
|
||||
assert Events.are_tags_linked(tag2, tag1)
|
||||
end
|
||||
|
||||
test "create_tag_relation/1 with invalid data returns error changeset", %{
|
||||
tag1: %Tag{} = tag1,
|
||||
tag2: %Tag{} = tag2
|
||||
} do
|
||||
assert {:error, %Ecto.Changeset{}} =
|
||||
Events.create_tag_relation(%{tag_id: nil, link_id: nil})
|
||||
|
||||
refute Events.are_tags_linked(tag1, tag2)
|
||||
end
|
||||
|
||||
test "delete_tag_relation/1 deletes the tag relation" do
|
||||
tag_relation = insert(:tag_relation)
|
||||
assert {:ok, %TagRelation{}} = Events.delete_tag_relation(tag_relation)
|
||||
end
|
||||
|
||||
test "tag_neighbors/2 return the connected tags for a given tag", %{
|
||||
tag1: %Tag{} = tag1,
|
||||
tag2: %Tag{} = tag2
|
||||
} do
|
||||
tag3 = insert(:tag)
|
||||
tag4 = insert(:tag)
|
||||
|
||||
assert {:ok, %TagRelation{}} =
|
||||
Events.create_tag_relation(%{tag_id: tag1.id, link_id: tag2.id})
|
||||
|
||||
assert {:ok, %TagRelation{}} =
|
||||
Events.create_tag_relation(%{tag_id: tag2.id, link_id: tag1.id})
|
||||
|
||||
assert {:ok, %TagRelation{}} =
|
||||
Events.create_tag_relation(%{tag_id: tag3.id, link_id: tag2.id})
|
||||
|
||||
assert {:ok, %TagRelation{}} =
|
||||
Events.create_tag_relation(%{tag_id: tag4.id, link_id: tag1.id})
|
||||
|
||||
assert {:ok, %TagRelation{}} =
|
||||
Events.create_tag_relation(%{tag_id: tag4.id, link_id: tag1.id})
|
||||
|
||||
assert {:ok, %TagRelation{}} =
|
||||
Events.create_tag_relation(%{tag_id: tag4.id, link_id: tag1.id})
|
||||
|
||||
assert {:error,
|
||||
%Ecto.Changeset{
|
||||
errors: [
|
||||
tag_id:
|
||||
{"Can't add a relation on self",
|
||||
[constraint: :check, constraint_name: "no_self_loops_check"]}
|
||||
]
|
||||
}} = Events.create_tag_relation(%{tag_id: tag1.id, link_id: tag1.id})
|
||||
|
||||
# The order is preserved, since tag4 has one more relation than tag2
|
||||
assert [tag4, tag2] == Events.tag_neighbors(tag1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "participants" do
|
||||
alias Mobilizon.Events.{Participant, Event}
|
||||
alias Mobilizon.Actors.Actor
|
||||
|
||||
@@ -34,7 +34,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-post-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", activity["object"])
|
||||
|
||||
# {:ok, returned_activity} = Transmogrifier.handle_incoming(data)
|
||||
@@ -45,7 +45,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
# test "it fetches replied-to activities if we don't have them" do
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-post-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
|
||||
# object =
|
||||
# data["object"]
|
||||
@@ -69,7 +69,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
# end
|
||||
|
||||
test "it works for incoming notices" do
|
||||
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
|
||||
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
|
||||
|
||||
{:ok, %Mobilizon.Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
@@ -103,7 +103,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
end
|
||||
|
||||
test "it works for incoming notices with hashtags" do
|
||||
data = File.read!("test/fixtures/mastodon-post-activity-hashtag.json") |> Poison.decode!()
|
||||
data = File.read!("test/fixtures/mastodon-post-activity-hashtag.json") |> Jason.decode!()
|
||||
|
||||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
assert Enum.at(data["object"]["tag"], 2) == "moo"
|
||||
@@ -111,7 +111,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# test "it works for incoming notices with contentMap" do
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-post-activity-contentmap.json") |> Poison.decode!()
|
||||
# File.read!("test/fixtures/mastodon-post-activity-contentmap.json") |> Jason.decode!()
|
||||
|
||||
# {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
@@ -120,7 +120,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
# end
|
||||
|
||||
# test "it works for incoming notices with to/cc not being an array (kroeg)" do
|
||||
# data = File.read!("test/fixtures/kroeg-post-activity.json") |> Poison.decode!()
|
||||
# data = File.read!("test/fixtures/kroeg-post-activity.json") |> Jason.decode!()
|
||||
|
||||
# {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
@@ -129,7 +129,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
# end
|
||||
|
||||
# test "it works for incoming announces with actor being inlined (kroeg)" do
|
||||
# data = File.read!("test/fixtures/kroeg-announce-with-inline-actor.json") |> Poison.decode!()
|
||||
# data = File.read!("test/fixtures/kroeg-announce-with-inline-actor.json") |> Jason.decode!()
|
||||
|
||||
# {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
@@ -137,7 +137,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
# end
|
||||
|
||||
# test "it works for incoming notices with tag not being an array (kroeg)" do
|
||||
# data = File.read!("test/fixtures/kroeg-array-less-emoji.json") |> Poison.decode!()
|
||||
# data = File.read!("test/fixtures/kroeg-array-less-emoji.json") |> Jason.decode!()
|
||||
|
||||
# {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
@@ -145,7 +145,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
# "icon_e_smile" => "https://puckipedia.com/forum/images/smilies/icon_e_smile.png"
|
||||
# }
|
||||
|
||||
# data = File.read!("test/fixtures/kroeg-array-less-hashtag.json") |> Poison.decode!()
|
||||
# data = File.read!("test/fixtures/kroeg-array-less-hashtag.json") |> Jason.decode!()
|
||||
|
||||
# {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
@@ -153,7 +153,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
# end
|
||||
|
||||
test "it works for incoming notices with url not being a string (prismo)" do
|
||||
data = File.read!("test/fixtures/prismo-url-map.json") |> Poison.decode!()
|
||||
data = File.read!("test/fixtures/prismo-url-map.json") |> Jason.decode!()
|
||||
|
||||
assert {:error, :not_supported} == Transmogrifier.handle_incoming(data)
|
||||
# Pages are not supported
|
||||
@@ -167,7 +167,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Jason.decode!()
|
||||
|> Map.put("object", actor.url)
|
||||
|
||||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
@@ -185,7 +185,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# data =
|
||||
# File.read!("test/fixtures/hubzilla-follow-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", user.ap_id)
|
||||
# |> Utils.normalize_params()
|
||||
|
||||
@@ -202,7 +202,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-like.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", url)
|
||||
|
||||
# {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
@@ -218,7 +218,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-undo-like.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", url)
|
||||
|
||||
# assert Transmogrifier.handle_incoming(data) == {:error, :not_supported}
|
||||
@@ -229,14 +229,14 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# like_data =
|
||||
# File.read!("test/fixtures/mastodon-like.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", comment.url)
|
||||
|
||||
# {:ok, %Activity{data: like_data, local: false}} = Transmogrifier.handle_incoming(like_data)
|
||||
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-undo-like.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", like_data)
|
||||
# |> Map.put("actor", like_data["actor"])
|
||||
|
||||
@@ -249,7 +249,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
# end
|
||||
|
||||
# test "it works for incoming announces" do
|
||||
# data = File.read!("test/fixtures/mastodon-announce.json") |> Poison.decode!()
|
||||
# data = File.read!("test/fixtures/mastodon-announce.json") |> Jason.decode!()
|
||||
|
||||
# {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
@@ -270,7 +270,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-announce.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", comment.url)
|
||||
|
||||
# {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
@@ -287,10 +287,10 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
# end
|
||||
|
||||
test "it works for incoming update activities" do
|
||||
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
|
||||
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
|
||||
|
||||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
update_data = File.read!("test/fixtures/mastodon-update.json") |> Poison.decode!()
|
||||
update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!()
|
||||
|
||||
object =
|
||||
update_data["object"]
|
||||
@@ -317,10 +317,10 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
end
|
||||
|
||||
# test "it works for incoming update activities which lock the account" do
|
||||
# data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
|
||||
# data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
|
||||
|
||||
# {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
# update_data = File.read!("test/fixtures/mastodon-update.json") |> Poison.decode!()
|
||||
# update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!()
|
||||
|
||||
# object =
|
||||
# update_data["object"]
|
||||
@@ -345,7 +345,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-delete.json")
|
||||
|> Poison.decode!()
|
||||
|> Jason.decode!()
|
||||
|
||||
object =
|
||||
data["object"]
|
||||
@@ -369,7 +369,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-delete.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
|
||||
# object =
|
||||
# data["object"]
|
||||
@@ -389,7 +389,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# announce_data =
|
||||
# File.read!("test/fixtures/mastodon-announce.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", comment.url)
|
||||
|
||||
# {:ok, %Activity{data: announce_data, local: false}} =
|
||||
@@ -397,7 +397,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-undo-announce.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", announce_data)
|
||||
# |> Map.put("actor", announce_data["actor"])
|
||||
|
||||
@@ -416,14 +416,14 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
follow_data =
|
||||
File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Jason.decode!()
|
||||
|> Map.put("object", actor.url)
|
||||
|
||||
{:ok, %Activity{data: _, local: false}} = Transmogrifier.handle_incoming(follow_data)
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-unfollow-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Jason.decode!()
|
||||
|> Map.put("object", follow_data)
|
||||
|
||||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
@@ -442,7 +442,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-block-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", user.ap_id)
|
||||
|
||||
# {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
@@ -462,7 +462,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-block-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", blocked.ap_id)
|
||||
# |> Map.put("actor", blocker.ap_id)
|
||||
|
||||
@@ -492,14 +492,14 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# block_data =
|
||||
# File.read!("test/fixtures/mastodon-block-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", user.ap_id)
|
||||
|
||||
# {:ok, %Activity{data: _, local: false}} = Transmogrifier.handle_incoming(block_data)
|
||||
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-unblock-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", block_data)
|
||||
|
||||
# {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
@@ -524,7 +524,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# accept_data =
|
||||
# File.read!("test/fixtures/mastodon-accept-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("actor", followed.ap_id)
|
||||
|
||||
# object =
|
||||
@@ -552,7 +552,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# accept_data =
|
||||
# File.read!("test/fixtures/mastodon-accept-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("actor", followed.ap_id)
|
||||
|
||||
# accept_data =
|
||||
@@ -574,7 +574,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# accept_data =
|
||||
# File.read!("test/fixtures/mastodon-accept-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("actor", followed.ap_id)
|
||||
# |> Map.put("object", follow_activity.data["id"])
|
||||
|
||||
@@ -592,7 +592,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# accept_data =
|
||||
# File.read!("test/fixtures/mastodon-accept-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("actor", followed.ap_id)
|
||||
|
||||
# accept_data =
|
||||
@@ -611,7 +611,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# accept_data =
|
||||
# File.read!("test/fixtures/mastodon-reject-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("actor", followed.ap_id)
|
||||
|
||||
# accept_data =
|
||||
@@ -635,7 +635,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# reject_data =
|
||||
# File.read!("test/fixtures/mastodon-reject-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("actor", followed.ap_id)
|
||||
|
||||
# reject_data =
|
||||
@@ -660,7 +660,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# reject_data =
|
||||
# File.read!("test/fixtures/mastodon-reject-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("actor", followed.ap_id)
|
||||
# |> Map.put("object", follow_activity.data["id"])
|
||||
|
||||
@@ -676,7 +676,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# data =
|
||||
# File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||
# |> Poison.decode!()
|
||||
# |> Jason.decode!()
|
||||
# |> Map.put("object", user.ap_id)
|
||||
# |> Map.put("id", "")
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ defmodule MobilizonWeb.ActivityPubControllerTest do
|
||||
describe "/@:preferred_username/inbox" do
|
||||
test "it inserts an incoming event into the database", %{conn: conn} do
|
||||
use_cassette "activity_pub_controller/mastodon-post-activity_actor_call" do
|
||||
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
|
||||
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
|
||||
|
||||
conn =
|
||||
conn
|
||||
|
||||
@@ -7,7 +7,7 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
|
||||
@event %{
|
||||
description: "some body",
|
||||
title: "some title",
|
||||
begins_on: Ecto.DateTime.utc(),
|
||||
begins_on: DateTime.utc_now() |> DateTime.truncate(:second),
|
||||
uuid: "b5126423-f1af-43e4-a923-002a03003ba4",
|
||||
url: "some url"
|
||||
}
|
||||
@@ -68,7 +68,9 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
|
||||
createEvent(
|
||||
title: "come to my event",
|
||||
description: "it will be fine",
|
||||
begins_on: "#{DateTime.utc_now() |> DateTime.to_iso8601()}",
|
||||
begins_on: "#{
|
||||
DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601()
|
||||
}",
|
||||
organizer_actor_id: "#{actor.id}",
|
||||
category: "#{category.title}"
|
||||
) {
|
||||
|
||||
@@ -7,7 +7,7 @@ defmodule MobilizonWeb.Resolvers.ParticipantResolverTest do
|
||||
@event %{
|
||||
description: "some body",
|
||||
title: "some title",
|
||||
begins_on: Ecto.DateTime.utc(),
|
||||
begins_on: DateTime.utc_now() |> DateTime.truncate(:second),
|
||||
uuid: "b5126423-f1af-43e4-a923-002a03003ba4",
|
||||
url: "some url"
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do
|
||||
|
||||
{:ok, %User{} = _user} =
|
||||
Actors.update_user(user, %{
|
||||
"confirmed_at" => DateTime.utc_now(),
|
||||
"confirmed_at" => DateTime.utc_now() |> DateTime.truncate(:second),
|
||||
"confirmation_sent_at" => nil,
|
||||
"confirmation_token" => nil
|
||||
})
|
||||
@@ -509,7 +509,7 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do
|
||||
|
||||
{:ok, %User{} = _user} =
|
||||
Actors.update_user(user, %{
|
||||
"confirmed_at" => DateTime.utc_now(),
|
||||
"confirmed_at" => DateTime.utc_now() |> DateTime.truncate(:second),
|
||||
"confirmation_sent_at" => nil,
|
||||
"confirmation_token" => nil
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ defmodule Mobilizon.Factory do
|
||||
password_hash: "Jane Smith",
|
||||
email: sequence(:email, &"email-#{&1}@example.com"),
|
||||
role: 0,
|
||||
confirmed_at: DateTime.utc_now(),
|
||||
confirmed_at: DateTime.utc_now() |> DateTime.truncate(:second),
|
||||
confirmation_sent_at: nil,
|
||||
confirmation_token: nil
|
||||
}
|
||||
@@ -67,6 +67,13 @@ defmodule Mobilizon.Factory do
|
||||
}
|
||||
end
|
||||
|
||||
def tag_relation_factory do
|
||||
%Mobilizon.Events.TagRelation{
|
||||
tag: build(:tag),
|
||||
link: build(:tag)
|
||||
}
|
||||
end
|
||||
|
||||
def address_factory do
|
||||
%Mobilizon.Addresses.Address{
|
||||
description: sequence("MyAddress"),
|
||||
|
||||
Reference in New Issue
Block a user