Fix tests

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-01-24 15:23:27 +01:00
parent 617b59c038
commit c660210439
9 changed files with 34 additions and 22 deletions

View File

@@ -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]

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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