Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ninja listings #201

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/bokken_web/controllers/skill/skill_json.ex
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
12 changes: 6 additions & 6 deletions test/bokken_web/controllers/skill_json_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down