Skip to content

Commit

Permalink
updated name of function in the GameFormHelpers
Browse files Browse the repository at this point in the history
  • Loading branch information
ZabGo committed Jul 10, 2024
1 parent 1c9fd71 commit 3d39957
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/copi_web/live/game_live/create_game_form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ defmodule CopiWeb.GameLive.CreateGameForm do
Cornucopia.change_game(%Game{
edition: "",
name: "",
suits: GameFormHelpers.generate_displayable_suits_from_suits_tuple_list("webapp")
suits: GameFormHelpers.generate_suit_list_formatted_for_checkbox("webapp")
})

{:ok,
Expand All @@ -67,7 +67,7 @@ defmodule CopiWeb.GameLive.CreateGameForm do
|> Cornucopia.change_game(%{
edition: game_params["edition"],
name: game_params["name"],
suits: GameFormHelpers.display_correct_suit_list(game_params["edition"], game_params["suits"])
suits: GameFormHelpers.display_appropriate_suits_list(game_params["edition"], game_params["suits"])
})
|> Map.put(:action, :validate)

Expand Down
8 changes: 4 additions & 4 deletions lib/copi_web/live/game_live/game_form_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule CopiWeb.GameLive.GameFormHelpers do
alias Copi.Cornucopia.Game
alias Copi.Games

def generate_displayable_suits_from_suits_tuple_list(edition) do
def generate_suit_list_formatted_for_checkbox(edition) do
format_list_of_suits_for_checkbox(edition)
|> Enum.map(fn {key, _} -> key end)
end
Expand All @@ -23,15 +23,15 @@ defmodule CopiWeb.GameLive.GameFormHelpers do
|> Enum.map(fn suit -> {"#{selected_edition}-#{suit}" , String.capitalize(suit) } end)
end

def display_correct_suit_list(edition, suits) do
def display_appropriate_suits_list(edition, suits) do
if hd(suits) == "" && length(suits) == 1 do
generate_displayable_suits_from_suits_tuple_list(edition)
generate_suit_list_formatted_for_checkbox(edition)
else
[_first, second | _rest] = suits
String.contains?(second, edition)
case String.contains?(second, edition) do
true -> suits
false -> generate_displayable_suits_from_suits_tuple_list(edition)
false -> generate_suit_list_formatted_for_checkbox(edition)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/copi_web/live/page_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ defmodule CopiWeb.PageLiveTest do
test "disconnected and connected render", %{conn: conn} do
{:ok, page_live, disconnected_html} = live(conn, "/")
assert disconnected_html =~ "Welcome to Phoenix!"
assert render(page_live) =~ "Welcome to Phoenix!"
assert render(page_live) = "Welcome to Phoenix!"
end
end

0 comments on commit 3d39957

Please sign in to comment.