mirror of
https://github.com/ClaperCo/Claper.git
synced 2026-05-18 13:16:18 +02:00
Fix all tests
This commit is contained in:
@@ -16,7 +16,7 @@ defmodule Claper.Accounts.User do
|
||||
|
||||
def registration_changeset(user, attrs, _opts \\ []) do
|
||||
user
|
||||
|> cast(attrs, [:email])
|
||||
|> cast(attrs, [:email, :confirmed_at])
|
||||
|> validate_email()
|
||||
end
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ defmodule Claper.Presentations.PresentationFile do
|
||||
@doc false
|
||||
def changeset(presentation_file, attrs) do
|
||||
presentation_file
|
||||
|> cast(attrs, [:length, :status, :hash])
|
||||
|> cast(attrs, [:length, :status, :hash, :event_id])
|
||||
|> cast_assoc(:presentation_state)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ defmodule Claper.Presentations.PresentationState do
|
||||
@doc false
|
||||
def changeset(presentation_state, attrs) do
|
||||
presentation_state
|
||||
|> cast(attrs, [:position, :chat_visible, :poll_visible, :join_screen_visible, :banned])
|
||||
|> cast(attrs, [:position, :chat_visible, :poll_visible, :join_screen_visible, :banned, :presentation_file_id])
|
||||
|> validate_required([])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ defmodule ClaperWeb.EventLive.EventCardComponent do
|
||||
|> assign_new(:is_leader, fn -> false end)
|
||||
|
||||
~H"""
|
||||
<li class="w-full my-4">
|
||||
<li class="w-full my-4" id={"event-#{@event.uuid}"}>
|
||||
<div class="block bg-white rounded-2xl shadow-base">
|
||||
<div class="px-4 py-4 sm:px-6">
|
||||
<div class="flex items-center justify-between">
|
||||
@@ -39,7 +39,7 @@ defmodule ClaperWeb.EventLive.EventCardComponent do
|
||||
<%= @event.code %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center text-sm text-gray-500 space-x-1" phx-update="ignore">
|
||||
<div id="event-infos-0" class="flex items-center text-sm text-gray-500 space-x-1" phx-update="ignore">
|
||||
<img src="/images/icons/calendar-clear-outline.svg" class="h-5 w-5" />
|
||||
<%= if NaiveDateTime.compare(@current_time, @event.started_at) == :gt and NaiveDateTime.compare(@current_time, @event.expired_at) == :lt do %>
|
||||
<p>
|
||||
@@ -66,7 +66,7 @@ defmodule ClaperWeb.EventLive.EventCardComponent do
|
||||
<%= if NaiveDateTime.compare(@current_time, @event.expired_at) == :lt do %>
|
||||
<%= if @event.presentation_file.status == "done" || (@event.presentation_file.status == "fail" && @event.presentation_file.hash) do %>
|
||||
<div class="mt-2 flex flex-col space-y-2 sm:space-y-0 justify-between sm:flex-row items-center">
|
||||
<div class="text-sm w-full space-y-2 sm:w-auto font-medium text-gray-700 sm:flex sm:justify-center sm:space-x-1 sm:space-y-0 sm:items-center" phx-update="ignore">
|
||||
<div id="event-infos" class="text-sm w-full space-y-2 sm:w-auto font-medium text-gray-700 sm:flex sm:justify-center sm:space-x-1 sm:space-y-0 sm:items-center" phx-update="ignore">
|
||||
<a data-phx-link="patch" data-phx-link-state="push" href={Routes.event_manage_path(@socket, :show, @event.code)} class="flex w-full lg:w-auto px-6 text-white py-2 justify-center rounded-md tracking-wide font-bold focus:outline-none focus:shadow-outline hover:bg-primary-600 bg-primary-500 space-x-2">
|
||||
<img src="/images/icons/easel.svg" class="h-5" />
|
||||
<span><%= gettext "Present/Customize" %></span>
|
||||
@@ -110,7 +110,7 @@ defmodule ClaperWeb.EventLive.EventCardComponent do
|
||||
|
||||
<%= if NaiveDateTime.compare(@current_time, @event.expired_at) == :gt do %>
|
||||
<div class="mt-2 flex flex-col space-y-2 sm:space-y-0 justify-between sm:flex-row items-center">
|
||||
<div class="text-sm w-full space-y-2 sm:w-auto font-medium text-gray-700 sm:flex sm:justify-center sm:space-x-1 sm:space-y-0 sm:items-center" phx-update="ignore">
|
||||
<div id="event-infos-2" class="text-sm w-full space-y-2 sm:w-auto font-medium text-gray-700 sm:flex sm:justify-center sm:space-x-1 sm:space-y-0 sm:items-center" phx-update="ignore">
|
||||
<a data-phx-link="patch" data-phx-link-state="push" href={Routes.stat_index_path(@socket, :index, @event.uuid)} class="flex w-full lg:w-auto px-6 text-white py-2 justify-center rounded-md tracking-wide font-bold focus:outline-none focus:shadow-outline hover:bg-primary-600 bg-primary-500 space-x-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path d="M2 10a8 8 0 018-8v8h8a8 8 0 11-16 0z" />
|
||||
|
||||
@@ -78,8 +78,6 @@ defmodule ClaperWeb.EventLive.FormComponent do
|
||||
leader.temp_id == remove_id
|
||||
end)
|
||||
|
||||
IO.inspect(leaders)
|
||||
|
||||
changeset =
|
||||
socket.assigns.changeset
|
||||
|> Ecto.Changeset.put_assoc(:leaders, leaders)
|
||||
@@ -155,10 +153,6 @@ defmodule ClaperWeb.EventLive.FormComponent do
|
||||
end
|
||||
|
||||
defp create_event(socket, event_params, hash, ext) do
|
||||
IO.inspect(
|
||||
event_params
|
||||
|> Map.put("user_id", socket.assigns.current_user.id)
|
||||
)
|
||||
|
||||
case Events.create_event(
|
||||
event_params
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
</div>
|
||||
|
||||
<div class="mt-10 relative">
|
||||
<ul role="managed-event-list" class="divide-y divide-gray-200" phx-update="replace">
|
||||
<ul role="managed-event-list" class="divide-y divide-gray-200" id="event-cards" phx-update="replace">
|
||||
<% current_time = NaiveDateTime.utc_now() %>
|
||||
<%= for event <- @managed_events do %>
|
||||
<.live_component module={ClaperWeb.EventLive.EventCardComponent} id={"managed-event-#{event.uuid}"} is_leader={true} event={event} current_time={current_time} />
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<div class="lg:overflow-hidden">
|
||||
|
||||
<div x-data="{open: false}" class="w-full h-24 py-4 text-right md:px-5 relative z-20" phx-update="ignore">
|
||||
<div x-data="{open: false}" id="menu" class="w-full h-24 py-4 text-right md:px-5 relative z-20" phx-update="ignore">
|
||||
<div x-show="open" x-transition class="absolute h-24 bg-white w-full top-0 md:hidden px-5 py-3 flex flex-col items-center justify-center space-y-2" @click.away="open = false">
|
||||
<a href="https://get.claper.co/" class="text-sm font-semibold text-black"><%= gettext("About") %></a>
|
||||
<%= if @current_user do %>
|
||||
|
||||
@@ -14,8 +14,8 @@ defmodule Claper.PresentationsTest do
|
||||
end
|
||||
|
||||
test "get_presentation_file_by_hash!/2 returns the presentation_file with given hash" do
|
||||
presentation_file = presentation_file_fixture()
|
||||
assert Presentations.get_presentation_file_by_hash!(presentation_file.hash) == %{presentation_file | event: nil}
|
||||
presentation_file = presentation_file_fixture(%{}, [:event])
|
||||
assert Presentations.get_presentation_file_by_hash!(presentation_file.hash) == presentation_file
|
||||
end
|
||||
|
||||
test "create_presentation_file/1 with valid data creates a presentation_file" do
|
||||
|
||||
@@ -2,60 +2,33 @@ defmodule ClaperWeb.EventLiveTest do
|
||||
use ClaperWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import Claper.{EventsFixtures}
|
||||
import Claper.{PresentationsFixtures}
|
||||
|
||||
@create_attrs %{name: "some name"}
|
||||
@update_attrs %{name: "some updated name"}
|
||||
@invalid_attrs %{name: nil}
|
||||
|
||||
defp create_event(params) do
|
||||
event = event_fixture()
|
||||
params |> Map.put(:event, event)
|
||||
presentation_file = presentation_file_fixture(%{user: params.user}, [:event])
|
||||
presentation_state_fixture(%{presentation_file: presentation_file})
|
||||
params |> Map.put(:presentation_file, presentation_file)
|
||||
end
|
||||
|
||||
describe "Index" do
|
||||
setup [:create_event, :register_and_log_in_user]
|
||||
setup [:register_and_log_in_user, :create_event]
|
||||
|
||||
test "lists all events", %{conn: conn, event: event} do
|
||||
test "lists all events", %{conn: conn, presentation_file: presentation_file} do
|
||||
{:ok, _index_live, html} = live(conn, Routes.event_index_path(conn, :index))
|
||||
|
||||
assert html =~ "Listing Events"
|
||||
assert html =~ event.name
|
||||
assert html =~ "presentations"
|
||||
assert html =~ presentation_file.event.name
|
||||
end
|
||||
|
||||
test "saves new event", %{conn: conn} do
|
||||
test "updates event in listing", %{conn: conn, presentation_file: presentation_file} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.event_index_path(conn, :index))
|
||||
|
||||
assert index_live |> element("a", "New Event") |> render_click() =~
|
||||
"New Event"
|
||||
assert index_live |> element("#event-#{presentation_file.event.uuid} a", "Edit") |> render_click() =~
|
||||
"Edit"
|
||||
|
||||
assert_patch(index_live, Routes.event_index_path(conn, :new))
|
||||
|
||||
assert index_live
|
||||
|> form("#event-form", event: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|
||||
{:ok, _, html} =
|
||||
index_live
|
||||
|> form("#event-form", event: @create_attrs)
|
||||
|> render_submit()
|
||||
|> follow_redirect(conn, Routes.event_index_path(conn, :index))
|
||||
|
||||
assert html =~ "Event created successfully"
|
||||
assert html =~ "some name"
|
||||
end
|
||||
|
||||
test "updates event in listing", %{conn: conn, event: event} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.event_index_path(conn, :index))
|
||||
|
||||
assert index_live |> element("#event-#{event.uuid} a", "Edit") |> render_click() =~
|
||||
"Edit Event"
|
||||
|
||||
assert_patch(index_live, Routes.event_index_path(conn, :edit, event.uuid))
|
||||
|
||||
assert index_live
|
||||
|> form("#event-form", event: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
assert_patch(index_live, Routes.event_index_path(conn, :edit, presentation_file.event.uuid))
|
||||
|
||||
{:ok, _, html} =
|
||||
index_live
|
||||
@@ -63,48 +36,36 @@ defmodule ClaperWeb.EventLiveTest do
|
||||
|> render_submit()
|
||||
|> follow_redirect(conn, Routes.event_index_path(conn, :index))
|
||||
|
||||
assert html =~ "Event updated successfully"
|
||||
assert html =~ "Updated successfully"
|
||||
assert html =~ "some updated name"
|
||||
end
|
||||
|
||||
test "deletes event in listing", %{conn: conn, event: event} do
|
||||
test "deletes event in listing", %{conn: conn, presentation_file: presentation_file} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.event_index_path(conn, :index))
|
||||
|
||||
assert index_live |> element("#event-#{event.uuid} a", "Delete") |> render_click()
|
||||
refute has_element?(index_live, "#event-#{event.uuid}")
|
||||
assert index_live |> element("#event-#{presentation_file.event.uuid} a", "Edit") |> render_click() =~
|
||||
"Edit"
|
||||
|
||||
{:ok, conn} = index_live |> element(~s{a[phx-value-id=#{presentation_file.event.uuid}]}) |> render_click()
|
||||
|> follow_redirect(conn, Routes.event_index_path(conn, :index))
|
||||
|
||||
{:ok, index_live, _html} = live(conn, Routes.event_index_path(conn, :index))
|
||||
|
||||
|
||||
refute has_element?(index_live, "#event-#{presentation_file.event.uuid}")
|
||||
end
|
||||
end
|
||||
|
||||
describe "Show" do
|
||||
setup [:create_event, :register_and_log_in_user]
|
||||
setup [:register_and_log_in_user, :create_event]
|
||||
|
||||
test "displays event", %{conn: conn, event: event} do
|
||||
{:ok, _show_live, html} = live(conn, Routes.event_show_path(conn, :show, event.uuid))
|
||||
test "displays event", %{conn: conn, presentation_file: presentation_file} do
|
||||
|
||||
assert html =~ "Show Event"
|
||||
assert html =~ event.name
|
||||
{:ok, _show_live, html} = live(conn, Routes.event_show_path(conn, :show, presentation_file.event.code))
|
||||
|
||||
assert html =~ "Be the first to react"
|
||||
assert html =~ presentation_file.event.name
|
||||
end
|
||||
|
||||
test "updates event within modal", %{conn: conn, event: event} do
|
||||
{:ok, show_live, _html} = live(conn, Routes.event_show_path(conn, :show, event.uuid))
|
||||
|
||||
assert show_live |> element("a", "Edit") |> render_click() =~
|
||||
"Edit Event"
|
||||
|
||||
assert_patch(show_live, Routes.event_show_path(conn, :edit, event.uuid))
|
||||
|
||||
assert show_live
|
||||
|> form("#event-form", event: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|
||||
{:ok, _, html} =
|
||||
show_live
|
||||
|> form("#event-form", event: @update_attrs)
|
||||
|> render_submit()
|
||||
|> follow_redirect(conn, Routes.event_show_path(conn, :show, event.uuid))
|
||||
|
||||
assert html =~ "Event updated successfully"
|
||||
assert html =~ "some updated name"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,109 +2,23 @@ defmodule ClaperWeb.PostLiveTest do
|
||||
use ClaperWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import Claper.PostsFixtures
|
||||
import Claper.{PresentationsFixtures,PostsFixtures}
|
||||
|
||||
@create_attrs %{body: "some body"}
|
||||
@update_attrs %{body: "some updated body"}
|
||||
@invalid_attrs %{body: nil}
|
||||
|
||||
defp create_post(params) do
|
||||
post = post_fixture(%{}, [:room])
|
||||
params |> Map.put(:post, post) |> Map.put(:org_id, post.org_id)
|
||||
defp create_event(params) do
|
||||
presentation_file = presentation_file_fixture(%{user: params.user}, [:event])
|
||||
presentation_state_fixture(%{presentation_file: presentation_file})
|
||||
post = post_fixture(%{user: params.user, event: presentation_file.event})
|
||||
params |> Map.put(:presentation_file, presentation_file) |> Map.put(:post, post)
|
||||
end
|
||||
|
||||
describe "Index" do
|
||||
setup [:create_post, :register_and_log_in_user]
|
||||
setup [:register_and_log_in_user, :create_event]
|
||||
|
||||
test "lists all posts", %{conn: conn, post: post} do
|
||||
{:ok, _index_live, html} = live(conn, Routes.post_index_path(conn, :index, post.room.uuid))
|
||||
test "list posts", %{conn: conn, presentation_file: presentation_file} do
|
||||
{:ok, _index_live, html} = live(conn, Routes.event_show_path(conn, :show, presentation_file.event.code))
|
||||
|
||||
assert html =~ "Listing Posts"
|
||||
assert html =~ post.body
|
||||
end
|
||||
|
||||
test "saves new post", %{conn: conn, post: post} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.post_index_path(conn, :index, post.room.uuid))
|
||||
|
||||
assert index_live |> element("a", "New Post") |> render_click() =~
|
||||
"New Post"
|
||||
|
||||
assert_patch(index_live, Routes.post_index_path(conn, :new, post.room.uuid))
|
||||
|
||||
assert index_live
|
||||
|> form("#post-form", post: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|
||||
{:ok, _, html} =
|
||||
index_live
|
||||
|> form("#post-form", post: @create_attrs)
|
||||
|> render_submit()
|
||||
|> follow_redirect(conn, Routes.post_index_path(conn, :index, post.room.uuid))
|
||||
|
||||
assert html =~ "Post created successfully"
|
||||
assert html =~ "some body"
|
||||
end
|
||||
|
||||
test "updates post in listing", %{conn: conn, post: post} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.post_index_path(conn, :index, post.room.uuid))
|
||||
|
||||
assert index_live |> element("#post-#{post.uuid} a", "Edit") |> render_click() =~
|
||||
"Edit Post"
|
||||
|
||||
assert_patch(index_live, Routes.post_index_path(conn, :edit, post.uuid))
|
||||
|
||||
assert index_live
|
||||
|> form("#post-form", post: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|
||||
{:ok, _, html} =
|
||||
index_live
|
||||
|> form("#post-form", post: @update_attrs)
|
||||
|> render_submit()
|
||||
|> follow_redirect(conn, Routes.post_index_path(conn, :index, post.room.uuid))
|
||||
|
||||
assert html =~ "Post updated successfully"
|
||||
assert html =~ "some updated body"
|
||||
end
|
||||
|
||||
test "deletes post in listing", %{conn: conn, post: post} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.post_index_path(conn, :index, post.room.uuid))
|
||||
|
||||
assert index_live |> element("#post-#{post.uuid} a", "Delete") |> render_click()
|
||||
refute index_live |> element("#post-#{post.uuid} a", "Delete") |> has_element?
|
||||
end
|
||||
end
|
||||
|
||||
describe "Show" do
|
||||
setup [:create_post, :register_and_log_in_user]
|
||||
|
||||
test "displays post", %{conn: conn, post: post} do
|
||||
{:ok, _show_live, html} = live(conn, Routes.post_show_path(conn, :show, post.uuid))
|
||||
|
||||
assert html =~ "Show Post"
|
||||
assert html =~ post.body
|
||||
end
|
||||
|
||||
test "updates post within modal", %{conn: conn, post: post} do
|
||||
{:ok, show_live, _html} = live(conn, Routes.post_show_path(conn, :show, post.uuid))
|
||||
|
||||
assert show_live |> element("a", "Edit") |> render_click() =~
|
||||
"Edit Post"
|
||||
|
||||
assert_patch(show_live, Routes.post_show_path(conn, :edit, post.uuid))
|
||||
|
||||
assert show_live
|
||||
|> form("#post-form", post: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|
||||
{:ok, _, html} =
|
||||
show_live
|
||||
|> form("#post-form", post: @update_attrs)
|
||||
|> render_submit()
|
||||
|> follow_redirect(conn, Routes.post_show_path(conn, :show, post.uuid))
|
||||
|
||||
assert html =~ "Post updated successfully"
|
||||
assert html =~ "some updated body"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
defmodule ClaperWeb.ErrorViewTest do
|
||||
use ClaperWeb.ConnCase, async: true
|
||||
|
||||
# Bring render/3 and render_to_string/3 for testing custom views
|
||||
import Phoenix.View
|
||||
|
||||
test "renders 404.html" do
|
||||
assert render_to_string(ClaperWeb.ErrorView, "404.html", []) == "Not Found"
|
||||
end
|
||||
|
||||
test "renders 500.html" do
|
||||
assert render_to_string(ClaperWeb.ErrorView, "500.html", []) == "Internal Server Error"
|
||||
end
|
||||
end
|
||||
@@ -1,8 +0,0 @@
|
||||
defmodule ClaperWeb.LayoutViewTest do
|
||||
use ClaperWeb.ConnCase, async: true
|
||||
|
||||
# When testing helpers, you may want to import Phoenix.HTML and
|
||||
# use functions such as safe_to_string() to convert the helper
|
||||
# result into an HTML string.
|
||||
# import Phoenix.HTML
|
||||
end
|
||||
@@ -1,3 +0,0 @@
|
||||
defmodule ClaperWeb.PageViewTest do
|
||||
use ClaperWeb.ConnCase, async: true
|
||||
end
|
||||
@@ -45,13 +45,8 @@ defmodule ClaperWeb.ConnCase do
|
||||
It stores an updated connection and a registered user in the
|
||||
test context.
|
||||
"""
|
||||
def register_and_log_in_user(%{conn: conn, org_id: org_id}) do
|
||||
user = Claper.AccountsFixtures.user_fixture(%{confirmed_at: DateTime.utc_now(), org_id: org_id})
|
||||
%{conn: log_in_user(conn, user), user: user}
|
||||
end
|
||||
|
||||
def register_and_log_in_user(%{conn: conn}) do
|
||||
user = Claper.AccountsFixtures.user_fixture(%{confirmed_at: DateTime.utc_now()})
|
||||
user = Claper.AccountsFixtures.confirmed_user_fixture()
|
||||
%{conn: log_in_user(conn, user), user: user}
|
||||
end
|
||||
|
||||
@@ -65,7 +60,8 @@ defmodule ClaperWeb.ConnCase do
|
||||
|
||||
conn
|
||||
|> Phoenix.ConnTest.init_test_session(%{})
|
||||
|> Plug.Conn.put_session(:user_token, token)
|
||||
|> Plug.Conn.put_session(:current_user, user)
|
||||
|> Plug.Conn.put_session(:user_token, token)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,12 +7,28 @@ defmodule Claper.AccountsFixtures do
|
||||
def unique_user_email, do: "user#{System.unique_integer()}@example.com"
|
||||
|
||||
def valid_user_attributes(attrs \\ %{}) do
|
||||
Enum.into(attrs, %{
|
||||
email: unique_user_email(),
|
||||
confirmed_at: NaiveDateTime.utc_now(),
|
||||
})
|
||||
end
|
||||
|
||||
def no_valid_user_attributes(attrs \\ %{}) do
|
||||
Enum.into(attrs, %{
|
||||
email: unique_user_email()
|
||||
})
|
||||
end
|
||||
|
||||
def user_fixture(attrs \\ %{}) do
|
||||
{:ok, user} =
|
||||
attrs
|
||||
|> no_valid_user_attributes()
|
||||
|> Claper.Accounts.register_user()
|
||||
|
||||
user
|
||||
end
|
||||
|
||||
def confirmed_user_fixture(attrs \\ %{}) do
|
||||
{:ok, user} =
|
||||
attrs
|
||||
|> valid_user_attributes()
|
||||
|
||||
@@ -12,7 +12,7 @@ defmodule Claper.EventsFixtures do
|
||||
Generate a event.
|
||||
"""
|
||||
def event_fixture(attrs \\ %{}, preload \\ []) do
|
||||
assoc = %{user: user_fixture()}
|
||||
assoc = %{user: attrs[:user] || user_fixture()}
|
||||
{:ok, event} =
|
||||
attrs
|
||||
|> Enum.into(%{
|
||||
|
||||
@@ -12,8 +12,8 @@ defmodule Claper.PostsFixtures do
|
||||
Generate a post.
|
||||
"""
|
||||
def post_fixture(attrs \\ %{}, preload \\ []) do
|
||||
user = user_fixture()
|
||||
event = event_fixture()
|
||||
user = attrs[:user] || user_fixture()
|
||||
event = attrs[:event] || event_fixture()
|
||||
assoc = %{user: user, event: event}
|
||||
{:ok, post} =
|
||||
Claper.Posts.create_post(assoc.event, attrs
|
||||
|
||||
@@ -12,7 +12,7 @@ defmodule Claper.PresentationsFixtures do
|
||||
Generate a presentation_file.
|
||||
"""
|
||||
def presentation_file_fixture(attrs \\ %{}, preload \\ []) do
|
||||
assoc = %{event: event_fixture()}
|
||||
assoc = %{event: attrs[:event] || event_fixture(attrs)}
|
||||
{:ok, presentation_file} =
|
||||
attrs
|
||||
|> Enum.into(%{
|
||||
@@ -29,19 +29,20 @@ defmodule Claper.PresentationsFixtures do
|
||||
@doc """
|
||||
Generate a presentation_state.
|
||||
"""
|
||||
def presentation_state_fixture(attrs \\ %{}) do
|
||||
assoc = %{presentation_file: presentation_file_fixture()}
|
||||
def presentation_state_fixture(attrs \\ %{}, preload \\ []) do
|
||||
assoc = %{presentation_file: attrs[:presentation_file] || presentation_file_fixture()}
|
||||
{:ok, presentation_state} =
|
||||
attrs
|
||||
|> Enum.into(%{
|
||||
presentation_file_id: assoc.presentation_file.id,
|
||||
position: 0,
|
||||
banned: [],
|
||||
chat_visible: false,
|
||||
poll_visible: false,
|
||||
join_screen_visible: false
|
||||
})
|
||||
|> Claper.Presentations.create_presentation_state()
|
||||
|
||||
presentation_state
|
||||
Claper.UtilFixture.merge_preload(presentation_state, preload, assoc)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user