Refactor Core things, including Ecto handling, ActivityPub & Transmogrifier modules
* Data doesn't need anymore to be converted to ActivityStream format to be saved (this was taken from Pleroma and not at all a good idea here) * Everything saved when creating an event is inserted into PostgreSQL in a single transaction
This commit is contained in:
@@ -18,8 +18,7 @@ defmodule MobilizonWeb.Plugs.UploadedMediaPlugTest do
|
||||
}
|
||||
|
||||
{:ok, data} = Upload.store(file)
|
||||
[%{"href" => attachment_url} | _] = data["url"]
|
||||
[attachment_url: attachment_url]
|
||||
[attachment_url: data.url]
|
||||
end
|
||||
|
||||
setup_all :upload_file
|
||||
|
||||
@@ -18,7 +18,7 @@ defmodule MobilizonWeb.Resolvers.CommentResolverTest do
|
||||
mutation {
|
||||
createComment(
|
||||
text: "#{@comment.text}",
|
||||
actor_username: "#{actor.preferred_username}"
|
||||
actor_id: "#{actor.id}"
|
||||
) {
|
||||
text,
|
||||
uuid
|
||||
|
||||
@@ -363,7 +363,7 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
|
||||
actor: actor,
|
||||
user: user
|
||||
} do
|
||||
address = insert(:address)
|
||||
address = %{street: "I am a street, please believe me", locality: "Where ever"}
|
||||
|
||||
mutation = """
|
||||
mutation {
|
||||
@@ -383,6 +383,7 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
|
||||
title,
|
||||
uuid,
|
||||
physicalAddress {
|
||||
id,
|
||||
url,
|
||||
geom,
|
||||
street
|
||||
@@ -403,8 +404,8 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
|
||||
assert json_response(res, 200)["data"]["createEvent"]["physicalAddress"]["street"] ==
|
||||
address.street
|
||||
|
||||
refute json_response(res, 200)["data"]["createEvent"]["physicalAddress"]["url"] ==
|
||||
address.url
|
||||
address_url = json_response(res, 200)["data"]["createEvent"]["physicalAddress"]["url"]
|
||||
address_id = json_response(res, 200)["data"]["createEvent"]["physicalAddress"]["id"]
|
||||
|
||||
mutation = """
|
||||
mutation {
|
||||
@@ -417,12 +418,13 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
|
||||
organizer_actor_id: "#{actor.id}",
|
||||
category: "birthday",
|
||||
physical_address: {
|
||||
url: "#{address.url}"
|
||||
id: "#{address_id}"
|
||||
}
|
||||
) {
|
||||
title,
|
||||
uuid,
|
||||
physicalAddress {
|
||||
id,
|
||||
url,
|
||||
geom,
|
||||
street
|
||||
@@ -443,8 +445,11 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
|
||||
assert json_response(res, 200)["data"]["createEvent"]["physicalAddress"]["street"] ==
|
||||
address.street
|
||||
|
||||
assert json_response(res, 200)["data"]["createEvent"]["physicalAddress"]["id"] ==
|
||||
address_id
|
||||
|
||||
assert json_response(res, 200)["data"]["createEvent"]["physicalAddress"]["url"] ==
|
||||
address.url
|
||||
address_url
|
||||
end
|
||||
|
||||
test "create_event/3 creates an event with an attached picture", %{
|
||||
@@ -501,7 +506,7 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
|
||||
"picture for my event"
|
||||
end
|
||||
|
||||
test "create_event/3 creates an event with an picture URL", %{
|
||||
test "create_event/3 creates an event with an picture ID", %{
|
||||
conn: conn,
|
||||
actor: actor,
|
||||
user: user
|
||||
|
||||
@@ -2,7 +2,6 @@ defmodule MobilizonWeb.Resolvers.GroupResolverTest do
|
||||
use MobilizonWeb.ConnCase
|
||||
alias MobilizonWeb.AbsintheHelpers
|
||||
import Mobilizon.Factory
|
||||
require Logger
|
||||
|
||||
@non_existent_username "nonexistent"
|
||||
@new_group_params %{groupname: "new group"}
|
||||
@@ -36,7 +35,7 @@ defmodule MobilizonWeb.Resolvers.GroupResolverTest do
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"Actor id is not owned by authenticated user"
|
||||
"Creator actor id is not owned by the current user"
|
||||
end
|
||||
|
||||
test "create_group/3 creates a group and check a group with this name does not already exist",
|
||||
|
||||
@@ -561,8 +561,8 @@ defmodule MobilizonWeb.Resolvers.ParticipantResolverTest do
|
||||
event(uuid: "#{event.uuid}") {
|
||||
uuid,
|
||||
participantStats {
|
||||
approved,
|
||||
unapproved,
|
||||
going,
|
||||
notApproved,
|
||||
rejected
|
||||
}
|
||||
}
|
||||
@@ -574,8 +574,8 @@ defmodule MobilizonWeb.Resolvers.ParticipantResolverTest do
|
||||
|> get("/api", AbsintheHelpers.query_skeleton(query, "event"))
|
||||
|
||||
assert json_response(res, 200)["data"]["event"]["uuid"] == to_string(event.uuid)
|
||||
assert json_response(res, 200)["data"]["event"]["participantStats"]["approved"] == 1
|
||||
assert json_response(res, 200)["data"]["event"]["participantStats"]["unapproved"] == 0
|
||||
assert json_response(res, 200)["data"]["event"]["participantStats"]["going"] == 1
|
||||
assert json_response(res, 200)["data"]["event"]["participantStats"]["notApproved"] == 0
|
||||
assert json_response(res, 200)["data"]["event"]["participantStats"]["rejected"] == 0
|
||||
|
||||
moderator = insert(:actor)
|
||||
@@ -586,18 +586,18 @@ defmodule MobilizonWeb.Resolvers.ParticipantResolverTest do
|
||||
actor_id: moderator.id
|
||||
})
|
||||
|
||||
unapproved = insert(:actor)
|
||||
not_approved = insert(:actor)
|
||||
|
||||
Events.create_participant(%{
|
||||
role: :not_approved,
|
||||
event_id: event.id,
|
||||
actor_id: unapproved.id
|
||||
actor_id: not_approved.id
|
||||
})
|
||||
|
||||
Events.create_participant(%{
|
||||
role: :rejected,
|
||||
event_id: event.id,
|
||||
actor_id: unapproved.id
|
||||
actor_id: not_approved.id
|
||||
})
|
||||
|
||||
query = """
|
||||
@@ -605,8 +605,8 @@ defmodule MobilizonWeb.Resolvers.ParticipantResolverTest do
|
||||
event(uuid: "#{event.uuid}") {
|
||||
uuid,
|
||||
participantStats {
|
||||
approved,
|
||||
unapproved,
|
||||
going,
|
||||
notApproved,
|
||||
rejected
|
||||
}
|
||||
}
|
||||
@@ -618,8 +618,8 @@ defmodule MobilizonWeb.Resolvers.ParticipantResolverTest do
|
||||
|> get("/api", AbsintheHelpers.query_skeleton(query, "event"))
|
||||
|
||||
assert json_response(res, 200)["data"]["event"]["uuid"] == to_string(event.uuid)
|
||||
assert json_response(res, 200)["data"]["event"]["participantStats"]["approved"] == 2
|
||||
assert json_response(res, 200)["data"]["event"]["participantStats"]["unapproved"] == 1
|
||||
assert json_response(res, 200)["data"]["event"]["participantStats"]["going"] == 2
|
||||
assert json_response(res, 200)["data"]["event"]["participantStats"]["notApproved"] == 1
|
||||
assert json_response(res, 200)["data"]["event"]["participantStats"]["rejected"] == 1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,9 +25,9 @@ defmodule Mobilizon.UploadTest do
|
||||
{:ok, data} = Upload.store(file)
|
||||
|
||||
assert %{
|
||||
"url" => [%{"href" => url, "mediaType" => "image/jpeg"}],
|
||||
"size" => 13_227,
|
||||
"type" => "Image"
|
||||
url: url,
|
||||
content_type: "image/jpeg",
|
||||
size: 13_227
|
||||
} = data
|
||||
|
||||
assert String.starts_with?(url, MobilizonWeb.Endpoint.url() <> "/media/")
|
||||
@@ -46,9 +46,7 @@ defmodule Mobilizon.UploadTest do
|
||||
|
||||
{:ok, data} = Upload.store(file, base_url: base_url)
|
||||
|
||||
assert %{"url" => [%{"href" => url}]} = data
|
||||
|
||||
assert String.starts_with?(url, base_url <> "/media/")
|
||||
assert String.starts_with?(data.url, base_url <> "/media/")
|
||||
end
|
||||
|
||||
test "copies the file to the configured folder with deduping" do
|
||||
@@ -62,7 +60,7 @@ defmodule Mobilizon.UploadTest do
|
||||
|
||||
{:ok, data} = Upload.store(file, filters: [MobilizonWeb.Upload.Filter.Dedupe])
|
||||
|
||||
assert List.first(data["url"])["href"] ==
|
||||
assert data.url ==
|
||||
MobilizonWeb.Endpoint.url() <>
|
||||
"/media/590523d60d3831ec92d05cdd871078409d5780903910efec5cd35ab1b0f19d11.jpg"
|
||||
end
|
||||
@@ -77,7 +75,7 @@ defmodule Mobilizon.UploadTest do
|
||||
}
|
||||
|
||||
{:ok, data} = Upload.store(file)
|
||||
assert data["name"] == "an [image.jpg"
|
||||
assert data.name == "an [image.jpg"
|
||||
end
|
||||
|
||||
test "fixes incorrect content type" do
|
||||
@@ -90,7 +88,7 @@ defmodule Mobilizon.UploadTest do
|
||||
}
|
||||
|
||||
{:ok, data} = Upload.store(file, filters: [MobilizonWeb.Upload.Filter.Dedupe])
|
||||
assert hd(data["url"])["mediaType"] == "image/jpeg"
|
||||
assert data.content_type == "image/jpeg"
|
||||
end
|
||||
|
||||
test "adds missing extension" do
|
||||
@@ -103,7 +101,7 @@ defmodule Mobilizon.UploadTest do
|
||||
}
|
||||
|
||||
{:ok, data} = Upload.store(file)
|
||||
assert data["name"] == "an [image.jpg"
|
||||
assert data.name == "an [image.jpg"
|
||||
end
|
||||
|
||||
test "fixes incorrect file extension" do
|
||||
@@ -116,7 +114,7 @@ defmodule Mobilizon.UploadTest do
|
||||
}
|
||||
|
||||
{:ok, data} = Upload.store(file)
|
||||
assert data["name"] == "an [image.jpg"
|
||||
assert data.name == "an [image.jpg"
|
||||
end
|
||||
|
||||
test "don't modify filename of an unknown type" do
|
||||
@@ -129,7 +127,7 @@ defmodule Mobilizon.UploadTest do
|
||||
}
|
||||
|
||||
{:ok, data} = Upload.store(file)
|
||||
assert data["name"] == "test.txt"
|
||||
assert data.name == "test.txt"
|
||||
end
|
||||
|
||||
test "copies the file to the configured folder with anonymizing filename" do
|
||||
@@ -143,7 +141,7 @@ defmodule Mobilizon.UploadTest do
|
||||
|
||||
{:ok, data} = Upload.store(file, filters: [MobilizonWeb.Upload.Filter.AnonymizeFilename])
|
||||
|
||||
refute data["name"] == "an [image.jpg"
|
||||
refute data.name == "an [image.jpg"
|
||||
end
|
||||
|
||||
test "escapes invalid characters in url" do
|
||||
@@ -156,9 +154,8 @@ defmodule Mobilizon.UploadTest do
|
||||
}
|
||||
|
||||
{:ok, data} = Upload.store(file)
|
||||
[attachment_url | _] = data["url"]
|
||||
|
||||
assert Path.basename(attachment_url["href"]) == "an%E2%80%A6%20image.jpg"
|
||||
assert Path.basename(data.url) == "an%E2%80%A6%20image.jpg"
|
||||
end
|
||||
|
||||
test "escapes reserved uri characters" do
|
||||
@@ -171,9 +168,8 @@ defmodule Mobilizon.UploadTest do
|
||||
}
|
||||
|
||||
{:ok, data} = Upload.store(file)
|
||||
[attachment_url | _] = data["url"]
|
||||
|
||||
assert Path.basename(attachment_url["href"]) ==
|
||||
assert Path.basename(data.url) ==
|
||||
"%3A%3F%23%5B%5D%40%21%24%26%5C%27%28%29%2A%2B%2C%3B%3D.jpg"
|
||||
end
|
||||
|
||||
@@ -210,9 +206,9 @@ defmodule Mobilizon.UploadTest do
|
||||
{:ok, data} = Upload.store(file)
|
||||
|
||||
assert %{
|
||||
"url" => [%{"href" => url, "mediaType" => "image/jpeg"}],
|
||||
"size" => 13_227,
|
||||
"type" => "Image"
|
||||
url: url,
|
||||
size: 13_227,
|
||||
content_type: "image/jpeg"
|
||||
} = data
|
||||
|
||||
assert String.starts_with?(url, MobilizonWeb.Endpoint.url() <> "/media/")
|
||||
|
||||
Reference in New Issue
Block a user