From 59d96964af1051d8a9e70394a927e76dfcb39448 Mon Sep 17 00:00:00 2001 From: daniel_sp Date: Mon, 9 Oct 2023 22:36:48 +0100 Subject: [PATCH] fix: ninja listings --- lib/bokken_web/controllers/skill/skill_json.ex | 6 +++--- test/bokken_web/controllers/skill_json_test.exs | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/bokken_web/controllers/skill/skill_json.ex b/lib/bokken_web/controllers/skill/skill_json.ex index c0527a0a..8530d08d 100644 --- a/lib/bokken_web/controllers/skill/skill_json.ex +++ b/lib/bokken_web/controllers/skill/skill_json.ex @@ -1,17 +1,17 @@ defmodule BokkenWeb.SkillJSON do def index(%{skills: skills}) do - %{data: for(skill <- skills, do: data(%{skill: skill}))} + %{data: for(skill <- skills, do: data(skill))} end def show(%{skill: skill}) do - %{data: data(%{skill: skill})} + %{data: data(skill)} end def error(%{reason: reason}) do %{error: reason} end - def data(%{skill: skill}) do + def data(skill) do %{ id: skill.id, name: skill.name, diff --git a/test/bokken_web/controllers/skill_json_test.exs b/test/bokken_web/controllers/skill_json_test.exs index 494c5355..d4780057 100644 --- a/test/bokken_web/controllers/skill_json_test.exs +++ b/test/bokken_web/controllers/skill_json_test.exs @@ -6,8 +6,8 @@ defmodule Bokken.SkillJSONTest do alias BokkenWeb.SkillJSON test "data" do - skill = build(:skill) - rendered_skill = SkillJSON.data(%{skill: skill}) + skill = insert(:skill) + rendered_skill = SkillJSON.data(skill) assert rendered_skill == %{ id: skill.id, @@ -17,19 +17,19 @@ defmodule Bokken.SkillJSONTest do end test "show" do - skill = build(:skill) + skill = insert(:skill) rendered_skill = SkillJSON.show(%{skill: skill}) assert rendered_skill == %{ - data: SkillJSON.data(%{skill: skill}) + data: SkillJSON.data(skill) } end test "index" do - skills = build_list(5, :skill) + skills = insert_list(5, :skill) rendered_skills = SkillJSON.index(%{skills: skills}) - expected_data = Enum.map(skills, &SkillJSON.data(%{skill: &1})) + expected_data = for(skill <- skills, do: SkillJSON.data(skill)) assert rendered_skills == %{ data: expected_data