Skip to content

Commit

Permalink
chore: remove warnings for mix test #269
Browse files Browse the repository at this point in the history
  • Loading branch information
nwittstruck committed Mar 27, 2024
1 parent 5c054aa commit d002c9d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 20 deletions.
8 changes: 4 additions & 4 deletions lib/mindwendel_web/live/idea_live/index_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ defmodule MindwendelWeb.IdeaLive.IndexComponent do
idea_label = Brainstormings.get_idea_label(idea_label_id)

case(Brainstormings.add_idea_label_to_idea(idea, idea_label)) do
{:ok, idea} ->
{:ok, _idea} ->
{:noreply, socket}

{:error, changeset} ->
{:error, _changeset} ->
{:noreply, socket}
end
end
Expand All @@ -74,10 +74,10 @@ defmodule MindwendelWeb.IdeaLive.IndexComponent do
idea_label = Brainstormings.get_idea_label(idea_label_id)

case(Brainstormings.remove_idea_label_from_idea(idea, idea_label)) do
{:ok, idea} ->
{:ok, _idea} ->
{:noreply, socket}

{:error, changeset} ->
{:error, _changeset} ->
{:noreply, socket}
end
end
Expand Down
11 changes: 4 additions & 7 deletions test/mindwendel/brainstormings/create_brainstorming_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ defmodule Mindwendel.Brainstormings.CreateBrainstormingTest do

alias Mindwendel.Brainstormings
alias Mindwendel.Brainstormings.Brainstorming
alias Mindwendel.Brainstormings.Idea
alias Mindwendel.Brainstormings.IdeaLabel
alias Mindwendel.Brainstormings.Like
alias Mindwendel.Attachments.Link
alias Mindwendel.Accounts.User

describe "#create_brainstorming" do
Expand Down Expand Up @@ -63,15 +60,15 @@ defmodule Mindwendel.Brainstormings.CreateBrainstormingTest do
])

brainstorming_id = brainstorming.id
assert [%Brainstorming{id: brainstorming_id}] = user.brainstormings
assert [%Brainstorming{id: brainstorming_id}] = user.created_brainstormings
assert [%Brainstorming{id: brainstorming_id}] = user.moderated_brainstormings
assert [%Brainstorming{id: ^brainstorming_id}] = user.brainstormings
assert [%Brainstorming{id: ^brainstorming_id}] = user.created_brainstormings
assert [%Brainstorming{id: ^brainstorming_id}] = user.moderated_brainstormings
assert user.brainstormings == user.created_brainstormings
assert user.moderated_brainstormings == user.created_brainstormings
end

test "does not create additional user", %{user: user} do
{:ok, brainstorming} = Brainstormings.create_brainstorming(user, @brainstorming_attrs)
{:ok, _brainstorming} = Brainstormings.create_brainstorming(user, @brainstorming_attrs)

assert Repo.one(User) == user
end
Expand Down
2 changes: 0 additions & 2 deletions test/mindwendel/brainstormings_test.exs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
defmodule Mindwendel.BrainstormingsTest do
use Mindwendel.DataCase
alias Mindwendel.Brainstormings.BrainstormingModeratingUser
alias Mindwendel.Accounts.BrainstormingUser
alias Mindwendel.Factory

alias Mindwendel.Brainstormings
alias Mindwendel.Brainstormings.Brainstorming
alias Mindwendel.Brainstormings.Idea
alias Mindwendel.Brainstormings.IdeaLabel
alias Mindwendel.Brainstormings.Like
alias Mindwendel.Attachments.Link
alias Mindwendel.Accounts.User
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ defmodule MindwendelWeb.BrainstormingControllerTest do

alias Mindwendel.Repo
alias Mindwendel.Brainstormings.Brainstorming
alias Mindwendel.Brainstormings
alias Mindwendel.Accounts.User

describe "create" do
Expand All @@ -19,7 +18,7 @@ defmodule MindwendelWeb.BrainstormingControllerTest do
end

test "adds current user as moderating user to the brainstorming", %{conn: conn} do
conn = post(conn, Routes.brainstorming_path(conn, :create), brainstorming: @valid_attrs)
post(conn, Routes.brainstorming_path(conn, :create), brainstorming: @valid_attrs)

assert %Brainstorming{moderating_users: [%User{id: _}]} =
Repo.one(Brainstorming) |> Repo.preload(:moderating_users)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ defmodule MindwendelWeb.BrainstormingLive.ShowIdeaDeleteTest do
|> init_test_session(%{current_user_id: moderating_user.id})
|> live(Routes.brainstorming_show_path(conn, :show, brainstorming))

rendered =
show_live_view
|> element(html_selector_button_idea_delete_link())
|> render_click()
show_live_view
|> element(html_selector_button_idea_delete_link())
|> render_click()

refute show_live_view
|> element(html_selector_button_idea_delete_link())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ defmodule MindwendelWeb.BrainstormingLive.ShowIdeaEditTest do

assert Mindwendel.Brainstormings.get_idea!(idea.id).user_id
assert moderator_user.id != Mindwendel.Brainstormings.get_idea!(idea.id).user_id
assert user_id = Mindwendel.Brainstormings.get_idea!(idea.id).user_id
assert ^user_id = Mindwendel.Brainstormings.get_idea!(idea.id).user_id
end

defp html_selector_button_idea_edit_link do
Expand Down
20 changes: 20 additions & 0 deletions test/mindwendel_web/live/live_helpers_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
defmodule MindwendelWeb.LiveHelpersTest do
use MindwendelWeb.ConnCase
import Phoenix.LiveViewTest

alias Mindwendel.Factory

setup do
%{brainstorming: Factory.insert!(:brainstorming)}
end

test "contains deletion date", %{
conn: conn,
brainstorming: brainstorming
} do
{:ok, _show_live_view, html} =
live(conn, Routes.brainstorming_show_path(conn, :show, brainstorming))

assert html =~ "in 29 days"
end
end

0 comments on commit d002c9d

Please sign in to comment.