Fix front-end, allow events to be created by a group, allow to get sessions from an event
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -30,7 +30,7 @@ defmodule EventosWeb.EventControllerTest do
|
||||
|
||||
describe "create event" do
|
||||
test "renders event when data is valid", %{conn: conn, user: user} do
|
||||
attrs = Map.put(@create_attrs, :organizer_id, user.account.id)
|
||||
attrs = Map.put(@create_attrs, :organizer_account_id, user.account.id)
|
||||
|
||||
category = insert(:category)
|
||||
attrs = Map.put(attrs, :category_id, category.id)
|
||||
@@ -44,12 +44,25 @@ defmodule EventosWeb.EventControllerTest do
|
||||
"begins_on" => "2010-04-17T14:00:00Z",
|
||||
"description" => "some description",
|
||||
"ends_on" => "2010-04-17T14:00:00Z",
|
||||
"title" => "some title"}
|
||||
"title" => "some title",
|
||||
"group" => nil,
|
||||
"organizer" => %{
|
||||
"description" => nil,
|
||||
"display_name" => nil,
|
||||
"domain" => nil,
|
||||
"id" => user.account.id,
|
||||
"suspended" => false,
|
||||
"uri" => "https://",
|
||||
"url" => "https://",
|
||||
"username" => user.account.username
|
||||
},
|
||||
"participants" => []
|
||||
}
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, user: user} do
|
||||
conn = auth_conn(conn, user)
|
||||
attrs = Map.put(@invalid_attrs, :organizer_id, user.account.id)
|
||||
attrs = Map.put(@invalid_attrs, :organizer_account_id, user.account.id)
|
||||
conn = post conn, event_path(conn, :create), event: attrs
|
||||
assert json_response(conn, 422)["errors"] != %{}
|
||||
end
|
||||
@@ -71,7 +84,7 @@ defmodule EventosWeb.EventControllerTest do
|
||||
|
||||
test "renders event when data is valid", %{conn: conn, event: %Event{id: id} = event, user: user} do
|
||||
conn = auth_conn(conn, user)
|
||||
attrs = Map.put(@update_attrs, :organizer_id, user.account.id)
|
||||
attrs = Map.put(@update_attrs, :organizer_account_id, user.account.id)
|
||||
conn = put conn, event_path(conn, :update, event), event: attrs
|
||||
assert %{"id" => ^id} = json_response(conn, 200)["data"]
|
||||
|
||||
@@ -81,12 +94,25 @@ defmodule EventosWeb.EventControllerTest do
|
||||
"begins_on" => "2011-05-18T15:01:01Z",
|
||||
"description" => "some updated description",
|
||||
"ends_on" => "2011-05-18T15:01:01Z",
|
||||
"title" => "some updated title"}
|
||||
"title" => "some updated title",
|
||||
"group" => nil,
|
||||
"organizer" => %{
|
||||
"description" => nil,
|
||||
"display_name" => nil,
|
||||
"domain" => nil,
|
||||
"id" => user.account.id,
|
||||
"suspended" => false,
|
||||
"uri" => "https://",
|
||||
"url" => "https://",
|
||||
"username" => user.account.username
|
||||
},
|
||||
"participants" => []
|
||||
}
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, event: event, user: user} do
|
||||
conn = auth_conn(conn, user)
|
||||
attrs = Map.put(@invalid_attrs, :organizer_id, user.account.id)
|
||||
attrs = Map.put(@invalid_attrs, :organizer_account_id, user.account.id)
|
||||
conn = put conn, event_path(conn, :update, event), event: attrs
|
||||
assert json_response(conn, 422)["errors"] != %{}
|
||||
end
|
||||
@@ -107,7 +133,7 @@ defmodule EventosWeb.EventControllerTest do
|
||||
|
||||
defp create_event(_) do
|
||||
account = insert(:account)
|
||||
event = insert(:event, organizer: account)
|
||||
event = insert(:event, organizer_account: account)
|
||||
{:ok, event: event, account: account}
|
||||
end
|
||||
|
||||
|
||||
@@ -40,8 +40,11 @@ defmodule EventosWeb.GroupControllerTest do
|
||||
"description" => "some description",
|
||||
"suspended" => true,
|
||||
"title" => "some title",
|
||||
"uri" => "some uri",
|
||||
"url" => "some url"}
|
||||
"uri" => "h",
|
||||
"url" => "h",
|
||||
"events" => [],
|
||||
"members" => []
|
||||
}
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, user: user} do
|
||||
@@ -66,7 +69,10 @@ defmodule EventosWeb.GroupControllerTest do
|
||||
"suspended" => false,
|
||||
"title" => "some updated title",
|
||||
"uri" => "some updated uri",
|
||||
"url" => "some updated url"}
|
||||
"url" => "some updated url",
|
||||
"events" => [],
|
||||
"members" => []
|
||||
}
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, group: group, user: user} do
|
||||
|
||||
@@ -18,7 +18,7 @@ defmodule EventosWeb.SessionControllerTest do
|
||||
setup %{conn: conn} do
|
||||
account = insert(:account)
|
||||
user = insert(:user, account: account)
|
||||
event = insert(:event, organizer: account)
|
||||
event = insert(:event, organizer_account: account)
|
||||
{:ok, conn: conn, user: user, event: event}
|
||||
end
|
||||
|
||||
@@ -32,10 +32,14 @@ defmodule EventosWeb.SessionControllerTest do
|
||||
describe "create session" do
|
||||
test "renders session when data is valid", %{conn: conn, user: user, event: event} do
|
||||
conn = auth_conn(conn, user)
|
||||
attrs = Map.put(@create_attrs, :event_id, event.id)
|
||||
event_id = event.id
|
||||
attrs = Map.put(@create_attrs, :event_id, event_id)
|
||||
conn = post conn, session_path(conn, :create), session: attrs
|
||||
assert %{"id" => id} = json_response(conn, 201)["data"]
|
||||
|
||||
conn = get conn, "/api/events/" <> Integer.to_string(event_id) <> "/sessions"
|
||||
assert hd(json_response(conn, 200)["data"])["id"] == id
|
||||
|
||||
conn = get conn, session_path(conn, :show, id)
|
||||
assert json_response(conn, 200)["data"] == %{
|
||||
"id" => id,
|
||||
|
||||
@@ -18,7 +18,7 @@ defmodule EventosWeb.TrackControllerTest do
|
||||
setup %{conn: conn} do
|
||||
account = insert(:account)
|
||||
user = insert(:user, account: account)
|
||||
event = insert(:event, organizer: account)
|
||||
event = insert(:event, organizer_account: account)
|
||||
{:ok, conn: conn, user: user, event: event}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user