Remove credo and use mix format, and lint everything
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -6,10 +6,29 @@ defmodule EventosWeb.EventControllerTest do
|
||||
alias Eventos.Events.Event
|
||||
alias Eventos.Export.ICalendar
|
||||
|
||||
@create_attrs %{begins_on: "2010-04-17 14:00:00.000000Z", description: "some description", ends_on: "2010-04-17 14:00:00.000000Z", title: "some title"}
|
||||
@update_attrs %{begins_on: "2011-05-18 15:01:01.000000Z", description: "some updated description", ends_on: "2011-05-18 15:01:01.000000Z", title: "some updated title"}
|
||||
@create_attrs %{
|
||||
begins_on: "2010-04-17 14:00:00.000000Z",
|
||||
description: "some description",
|
||||
ends_on: "2010-04-17 14:00:00.000000Z",
|
||||
title: "some title"
|
||||
}
|
||||
@update_attrs %{
|
||||
begins_on: "2011-05-18 15:01:01.000000Z",
|
||||
description: "some updated description",
|
||||
ends_on: "2011-05-18 15:01:01.000000Z",
|
||||
title: "some updated title"
|
||||
}
|
||||
@invalid_attrs %{begins_on: nil, description: nil, ends_on: nil, title: nil, address_id: nil}
|
||||
@create_address_attrs %{"addressCountry" => "some addressCountry", "addressLocality" => "some addressLocality", "addressRegion" => "some addressRegion", "description" => "some description", "floor" => "some floor", "postalCode" => "some postalCode", "streetAddress" => "some streetAddress", "geom" => %{"type" => :point, "data" => %{"latitude" => -20, "longitude" => 30}}}
|
||||
@create_address_attrs %{
|
||||
"addressCountry" => "some addressCountry",
|
||||
"addressLocality" => "some addressLocality",
|
||||
"addressRegion" => "some addressRegion",
|
||||
"description" => "some description",
|
||||
"floor" => "some floor",
|
||||
"postalCode" => "some postalCode",
|
||||
"streetAddress" => "some streetAddress",
|
||||
"geom" => %{"type" => :point, "data" => %{"latitude" => -20, "longitude" => 30}}
|
||||
}
|
||||
|
||||
def fixture(:event) do
|
||||
{:ok, event} = Events.create_event(@create_attrs)
|
||||
@@ -28,7 +47,7 @@ defmodule EventosWeb.EventControllerTest do
|
||||
|
||||
describe "index" do
|
||||
test "lists all events", %{conn: conn} do
|
||||
conn = get conn, event_path(conn, :index)
|
||||
conn = get(conn, event_path(conn, :index))
|
||||
assert json_response(conn, 200)["data"] == []
|
||||
end
|
||||
end
|
||||
@@ -41,25 +60,37 @@ defmodule EventosWeb.EventControllerTest do
|
||||
category = insert(:category)
|
||||
attrs = Map.put(attrs, :category_id, category.id)
|
||||
conn = auth_conn(conn, user)
|
||||
conn = post conn, event_path(conn, :create), event: attrs
|
||||
conn = post(conn, event_path(conn, :create), event: attrs)
|
||||
assert %{"uuid" => uuid} = json_response(conn, 201)["data"]
|
||||
|
||||
conn = get conn, event_path(conn, :show, uuid)
|
||||
conn = get(conn, event_path(conn, :show, uuid))
|
||||
|
||||
assert %{
|
||||
"begins_on" => "2010-04-17T14:00:00Z",
|
||||
"description" => "some description",
|
||||
"ends_on" => "2010-04-17T14:00:00Z",
|
||||
"title" => "some title",
|
||||
"participants" => [],
|
||||
"physical_address" => %{"addressCountry" => "some addressCountry", "addressLocality" => "some addressLocality", "addressRegion" => "some addressRegion", "floor" => "some floor", "geom" => %{"data" => %{"latitude" => -20.0, "longitude" => 30.0}, "type" => "point"}, "postalCode" => "some postalCode", "streetAddress" => "some streetAddress"}
|
||||
} = json_response(conn, 200)["data"]
|
||||
"begins_on" => "2010-04-17T14:00:00Z",
|
||||
"description" => "some description",
|
||||
"ends_on" => "2010-04-17T14:00:00Z",
|
||||
"title" => "some title",
|
||||
"participants" => [],
|
||||
"physical_address" => %{
|
||||
"addressCountry" => "some addressCountry",
|
||||
"addressLocality" => "some addressLocality",
|
||||
"addressRegion" => "some addressRegion",
|
||||
"floor" => "some floor",
|
||||
"geom" => %{
|
||||
"data" => %{"latitude" => -20.0, "longitude" => 30.0},
|
||||
"type" => "point"
|
||||
},
|
||||
"postalCode" => "some postalCode",
|
||||
"streetAddress" => "some streetAddress"
|
||||
}
|
||||
} = json_response(conn, 200)["data"]
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, user: user, actor: actor} do
|
||||
conn = auth_conn(conn, user)
|
||||
attrs = Map.put(@invalid_attrs, :organizer_actor_id, actor.id)
|
||||
attrs = Map.put(attrs, :address, @create_address_attrs)
|
||||
conn = post conn, event_path(conn, :create), event: attrs
|
||||
conn = post(conn, event_path(conn, :create), event: attrs)
|
||||
assert json_response(conn, 422)["errors"] != %{}
|
||||
end
|
||||
end
|
||||
@@ -67,9 +98,13 @@ defmodule EventosWeb.EventControllerTest do
|
||||
describe "export event" do
|
||||
setup [:create_event]
|
||||
|
||||
test "renders ics export of event", %{conn: conn, event: %Event{uuid: uuid} = event, user: user} do
|
||||
test "renders ics export of event", %{
|
||||
conn: conn,
|
||||
event: %Event{uuid: uuid} = event,
|
||||
user: user
|
||||
} do
|
||||
conn = auth_conn(conn, user)
|
||||
conn = get conn, event_path(conn, :export_to_ics, uuid)
|
||||
conn = get(conn, event_path(conn, :export_to_ics, uuid))
|
||||
exported_event = ICalendar.export_event(event)
|
||||
assert exported_event == response(conn, 200)
|
||||
end
|
||||
@@ -78,29 +113,51 @@ defmodule EventosWeb.EventControllerTest do
|
||||
describe "update event" do
|
||||
setup [:create_event]
|
||||
|
||||
test "renders event when data is valid", %{conn: conn, event: %Event{uuid: uuid} = event, user: user, actor: actor} do
|
||||
test "renders event when data is valid", %{
|
||||
conn: conn,
|
||||
event: %Event{uuid: uuid} = event,
|
||||
user: user,
|
||||
actor: actor
|
||||
} do
|
||||
conn = auth_conn(conn, user)
|
||||
address = address_fixture()
|
||||
attrs = Map.put(@update_attrs, :organizer_actor_id, actor.id)
|
||||
attrs = Map.put(attrs, :address_id, address.id)
|
||||
conn = put conn, event_path(conn, :update, uuid), event: attrs
|
||||
conn = put(conn, event_path(conn, :update, uuid), event: attrs)
|
||||
assert %{"uuid" => uuid} = json_response(conn, 200)["data"]
|
||||
|
||||
conn = get conn, event_path(conn, :show, uuid)
|
||||
conn = get(conn, event_path(conn, :show, uuid))
|
||||
|
||||
assert %{
|
||||
"begins_on" => "2011-05-18T15:01:01Z",
|
||||
"description" => "some updated description",
|
||||
"ends_on" => "2011-05-18T15:01:01Z",
|
||||
"title" => "some updated title",
|
||||
"participants" => [],
|
||||
"physical_address" => %{"addressCountry" => "My Country", "addressLocality" => "My Locality", "addressRegion" => "My Region", "floor" => "Myfloor", "geom" => %{"data" => %{"latitude" => 30.0, "longitude" => -90.0}, "type" => "point"}, "postalCode" => "My Postal Code", "streetAddress" => "My Street Address"}
|
||||
"physical_address" => %{
|
||||
"addressCountry" => "My Country",
|
||||
"addressLocality" => "My Locality",
|
||||
"addressRegion" => "My Region",
|
||||
"floor" => "Myfloor",
|
||||
"geom" => %{
|
||||
"data" => %{"latitude" => 30.0, "longitude" => -90.0},
|
||||
"type" => "point"
|
||||
},
|
||||
"postalCode" => "My Postal Code",
|
||||
"streetAddress" => "My Street Address"
|
||||
}
|
||||
} = json_response(conn, 200)["data"]
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, event: %Event{uuid: uuid} = event, user: user, actor: actor} do
|
||||
test "renders errors when data is invalid", %{
|
||||
conn: conn,
|
||||
event: %Event{uuid: uuid} = event,
|
||||
user: user,
|
||||
actor: actor
|
||||
} do
|
||||
conn = auth_conn(conn, user)
|
||||
attrs = Map.put(@invalid_attrs, :organizer_actor_id, actor.id)
|
||||
conn = put conn, event_path(conn, :update, uuid), event: attrs
|
||||
conn = put(conn, event_path(conn, :update, uuid), event: attrs)
|
||||
assert json_response(conn, 422)["errors"] != %{}
|
||||
end
|
||||
end
|
||||
@@ -110,9 +167,9 @@ defmodule EventosWeb.EventControllerTest do
|
||||
|
||||
test "deletes chosen event", %{conn: conn, event: %Event{uuid: uuid} = event, user: user} do
|
||||
conn = auth_conn(conn, user)
|
||||
conn = delete conn, event_path(conn, :delete, uuid)
|
||||
conn = delete(conn, event_path(conn, :delete, uuid))
|
||||
assert response(conn, 204)
|
||||
conn = get conn, event_path(conn, :show, uuid)
|
||||
conn = get(conn, event_path(conn, :show, uuid))
|
||||
assert response(conn, 404)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user