Fix tests
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
617b59c038
commit
c660210439
@ -4,7 +4,6 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
"""
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Activity
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Events.Event
|
||||
|
||||
# We limit the max number of events that can be retrieved
|
||||
@ -79,7 +78,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
@doc """
|
||||
Create an event
|
||||
"""
|
||||
def create_event(_parent, args, %{context: %{current_user: user}}) do
|
||||
def create_event(_parent, args, %{context: %{current_user: _user}}) do
|
||||
with {:ok, %Activity{data: %{"object" => %{"type" => "Event"} = object}}} <-
|
||||
MobilizonWeb.API.Events.create_event(args) do
|
||||
{:ok,
|
||||
|
@ -52,7 +52,7 @@ defmodule MobilizonWeb.Resolvers.Person do
|
||||
{:error, "You need to be logged-in to view your list of identities"}
|
||||
end
|
||||
|
||||
def create_person(_parent, %{preferred_username: preferred_username} = args, %{
|
||||
def create_person(_parent, %{preferred_username: _preferred_username} = args, %{
|
||||
context: %{current_user: user}
|
||||
}) do
|
||||
args = Map.put(args, :user_id, user.id)
|
||||
@ -60,7 +60,7 @@ defmodule MobilizonWeb.Resolvers.Person do
|
||||
with {:ok, %Actor{} = new_person} <- Actors.new_person(args) do
|
||||
{:ok, new_person}
|
||||
else
|
||||
{:error, %Ecto.Changeset{} = e} ->
|
||||
{:error, %Ecto.Changeset{} = _e} ->
|
||||
{:error, "Unable to create a profile with this username"}
|
||||
end
|
||||
end
|
||||
|
4
mix.exs
4
mix.exs
@ -56,8 +56,8 @@ defmodule Mobilizon.Mixfile do
|
||||
{:phoenix_html, "~> 2.10"},
|
||||
{:gettext, "~> 0.11"},
|
||||
{:cowboy, "~> 1.0"},
|
||||
{:guardian, "~> 1.0"},
|
||||
{:guardian_db, "~> 1.0"},
|
||||
{:guardian, "~> 1.2"},
|
||||
{:guardian_db, "~> 1.1"},
|
||||
{:comeonin, "~> 4.0"},
|
||||
{:argon2_elixir, "~> 1.2"},
|
||||
{:cors_plug, "~> 1.2"},
|
||||
|
4
mix.lock
4
mix.lock
@ -45,7 +45,7 @@
|
||||
"geo_postgis": {:hex, :geo_postgis, "2.1.0", "e0640d18276cb1dd58aeae3f5eed9a61641a5110901e1e35d0d662031d936b33", [:mix], [{:geo, "~> 3.0", [hex: :geo, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.13", [hex: :postgrex, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"geolix": {:hex, :geolix, "0.17.0", "8f3f4068be08599912de67ae24372a6c148794a0152f9f83ffd5a2ffcb21d29a", [:mix], [{:mmdb2_decoder, "~> 0.3.0", [hex: :mmdb2_decoder, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.0", [hex: :poolboy, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"gettext": {:hex, :gettext, "0.16.1", "e2130b25eebcbe02bb343b119a07ae2c7e28bd4b146c4a154da2ffb2b3507af2", [:mix], [], "hexpm"},
|
||||
"guardian": {:hex, :guardian, "1.1.1", "be14c4007eaf05268251ae114030cb7237ed9a9631c260022f020164ff4ed733", [:mix], [{:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.0 or ~> 1.2 or ~> 1.3", [hex: :phoenix, repo: "hexpm", optional: true]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"guardian": {:hex, :guardian, "1.2.1", "bdc8dd3dbf0fb7216cb6f91c11831faa1a64d39cdaed9a611e37f2413e584983", [:mix], [{:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.3", [hex: :phoenix, repo: "hexpm", optional: true]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm"},
|
||||
"guardian_db": {:hex, :guardian_db, "1.1.0", "45ab94206cce38f7443dc27de6dc52966ccbdeff65ca1b1f11a6d8f3daceb556", [:mix], [{:ecto, "~> 2.2", [hex: :ecto, repo: "hexpm", optional: false]}, {:guardian, "~> 1.0", [hex: :guardian, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm"},
|
||||
"hackney": {:hex, :hackney, "1.14.3", "b5f6f5dcc4f1fba340762738759209e21914516df6be440d85772542d4a5e412", [:rebar3], [{:certifi, "2.4.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"http_sign": {:hex, :http_sign, "0.1.1", "b16edb83aa282892f3271f9a048c155e772bf36e15700ab93901484c55f8dd10", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
@ -53,7 +53,7 @@
|
||||
"icalendar": {:hex, :icalendar, "0.7.0", "6acf28c7e38ad1c4515c59e336878fb78bb646c8aa70d2ee3786ea194711a7b7", [:mix], [{:timex, "~> 3.0", [hex: :timex, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
|
||||
"jose": {:hex, :jose, "1.8.4", "7946d1e5c03a76ac9ef42a6e6a20001d35987afd68c2107bcd8f01a84e75aa73", [:mix, :rebar3], [{:base64url, "~> 0.0.1", [hex: :base64url, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"jose": {:hex, :jose, "1.9.0", "4167c5f6d06ffaebffd15cdb8da61a108445ef5e85ab8f5a7ad926fdf3ada154", [:mix, :rebar3], [{:base64url, "~> 0.0.1", [hex: :base64url, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"json_ld": {:hex, :json_ld, "0.3.0", "92f508ca831b9e4530e3e6c950976fdafcf26323e6817c325b3e1ee78affc4bd", [:mix], [{:jason, "~> 1.1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:rdf, "~> 0.5", [hex: :rdf, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm"},
|
||||
"kronky": {:hex, :kronky, "0.5.0", "b2038c267f02b297044cb574f542fa96763278a88b32a97d0c37bde95c63c13b", [:mix], [{:absinthe, "~> 1.3", [hex: :absinthe, repo: "hexpm", optional: false]}, {:ecto, ">= 2.1.4", [hex: :ecto, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
|
@ -69,14 +69,14 @@ defmodule Mobilizon.ActorsTest do
|
||||
assert actor_id == Actors.get_actor_for_user(user).id
|
||||
end
|
||||
|
||||
test "get_actor_with_everything!/1 returns the actor with it's organized events", %{
|
||||
test "get_actor_with_everything/1 returns the actor with it's organized events", %{
|
||||
actor: actor
|
||||
} do
|
||||
assert Actors.get_actor_with_everything!(actor.id).organized_events == []
|
||||
assert Actors.get_actor_with_everything(actor.id).organized_events == []
|
||||
event = insert(:event, organizer_actor: actor)
|
||||
|
||||
event_found_id =
|
||||
Actors.get_actor_with_everything!(actor.id).organized_events |> hd |> Map.get(:id)
|
||||
Actors.get_actor_with_everything(actor.id).organized_events |> hd |> Map.get(:id)
|
||||
|
||||
assert event_found_id == event.id
|
||||
end
|
||||
@ -573,15 +573,15 @@ defmodule Mobilizon.ActorsTest do
|
||||
|
||||
test "follow/3 makes an actor follow another", %{actor: actor, target_actor: target_actor} do
|
||||
# Preloading followers/followings
|
||||
actor = Actors.get_actor_with_everything!(actor.id)
|
||||
target_actor = Actors.get_actor_with_everything!(target_actor.id)
|
||||
actor = Actors.get_actor_with_everything(actor.id)
|
||||
target_actor = Actors.get_actor_with_everything(target_actor.id)
|
||||
|
||||
{:ok, follower} = Actor.follow(target_actor, actor)
|
||||
assert follower.actor.id == actor.id
|
||||
|
||||
# Referesh followers/followings
|
||||
actor = Actors.get_actor_with_everything!(actor.id)
|
||||
target_actor = Actors.get_actor_with_everything!(target_actor.id)
|
||||
actor = Actors.get_actor_with_everything(actor.id)
|
||||
target_actor = Actors.get_actor_with_everything(target_actor.id)
|
||||
|
||||
assert target_actor.followers |> Enum.map(& &1.actor_id) == [actor.id]
|
||||
assert actor.followings |> Enum.map(& &1.target_actor_id) == [target_actor.id]
|
||||
|
@ -9,7 +9,9 @@ defmodule Mobilizon.EventsTest do
|
||||
begins_on: "2010-04-17 14:00:00.000000Z",
|
||||
description: "some description",
|
||||
ends_on: "2010-04-17 14:00:00.000000Z",
|
||||
title: "some title"
|
||||
title: "some title",
|
||||
url: "some url",
|
||||
uuid: "b5126423-f1af-43e4-a923-002a03003ba4"
|
||||
}
|
||||
|
||||
describe "events" do
|
||||
|
@ -176,7 +176,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
assert data["type"] == "Follow"
|
||||
assert data["id"] == "https://social.tcit.fr/users/tcit#follows/2"
|
||||
|
||||
actor = Actors.get_actor_with_everything!(actor.id)
|
||||
actor = Actors.get_actor_with_everything(actor.id)
|
||||
assert Actor.following?(Actors.get_actor_by_url!(data["actor"], true), actor)
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,13 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
|
||||
alias MobilizonWeb.AbsintheHelpers
|
||||
import Mobilizon.Factory
|
||||
|
||||
@event %{description: "some body", title: "some title", begins_on: Ecto.DateTime.utc()}
|
||||
@event %{
|
||||
description: "some body",
|
||||
title: "some title",
|
||||
begins_on: Ecto.DateTime.utc(),
|
||||
uuid: "b5126423-f1af-43e4-a923-002a03003ba4",
|
||||
url: "some url"
|
||||
}
|
||||
|
||||
setup %{conn: conn} do
|
||||
{:ok, %User{default_actor: %Actor{} = actor} = user} =
|
||||
@ -117,7 +123,7 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
|
||||
title: "come to my event",
|
||||
description: "it will be fine",
|
||||
begins_on: "#{DateTime.utc_now() |> DateTime.to_iso8601()}",
|
||||
organizer_actor_username: "#{actor.preferred_username}",
|
||||
organizer_actor_id: "#{actor.id}",
|
||||
category: "#{category.title}"
|
||||
) {
|
||||
title,
|
||||
@ -131,6 +137,8 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
|
||||
|> auth_conn(user)
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
require Logger
|
||||
Logger.error(inspect(json_response(res, 200)))
|
||||
assert json_response(res, 200)["data"]["createEvent"]["title"] == "come to my event"
|
||||
end
|
||||
|
||||
|
@ -336,7 +336,8 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do
|
||||
context.conn
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] == "password_too_short"
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"The password you have choosen is too short. Please make sure your password contains at least 6 charaters."
|
||||
end
|
||||
|
||||
test "test reset_password/3 with an invalid token", context do
|
||||
@ -361,7 +362,8 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do
|
||||
context.conn
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] == "invalid_token"
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"The token you provided is invalid. Make sure that the URL is exactly the one provided inside the email you got."
|
||||
end
|
||||
end
|
||||
|
||||
@ -431,7 +433,8 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do
|
||||
context.conn
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] == "Impossible to authenticate"
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"Impossible to authenticate, either your email or password are invalid."
|
||||
end
|
||||
|
||||
test "test login_user/3 with invalid email", context do
|
||||
|
Loading…
Reference in New Issue
Block a user