Skip to content

Commit 12f6808

Browse files
committed
update task list controller
1 parent bb6d1eb commit 12f6808

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

lib/code_corps_web/controllers/task_list_controller.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ defmodule CodeCorpsWeb.TaskListController do
1919
|> Repo.all()
2020
|> preload()
2121

22-
conn |> render(TaskListView, "index.json-api", %{data: task_lists, conn: conn})
22+
conn |> render(TaskListView, "index.json", %{data: task_lists, conn: conn})
2323
end
2424

2525
@spec show(Conn.t, map) :: Conn.t
2626
def show(%Conn{} = conn, %{"id" => id}) do
2727
with %TaskList{} = task_list <- TaskList |> Repo.get(id) |> preload() do
28-
conn |> render(TaskListView, "show.json-api", %{data: task_list, conn: conn, params: id})
28+
conn |> render(TaskListView, "show.json", %{data: task_list, conn: conn, params: id})
2929
end
3030
end
3131

lib/code_corps_web/views/task_list_view.ex

+3-11
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,9 @@ defmodule CodeCorpsWeb.TaskListView do
55

66
alias CodeCorpsWeb.{ProjectView, TaskView}
77

8-
def render("index.json-api", %{data: task_list, conn: conn}) do
9-
__MODULE__.index(task_list, conn, nil)
10-
end
11-
12-
def render("show.json-api", %{data: task_list, conn: conn, params: params}) do
13-
__MODULE__.show(task_list, conn, params)
14-
end
15-
168
def fields, do: [:done, :inbox, :name, :order, :pull_requests, :inserted_at, :updated_at]
179

18-
# def relationships do
19-
# [project: ProjectView, tasks: TaskView]
20-
# end
10+
def relationships do
11+
[project: ProjectView, tasks: TaskView]
12+
end
2113
end

test/lib/code_corps_web/views/task_list_view_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ defmodule CodeCorpsWeb.TaskListViewTest do
88
task = insert(:task, order: 1000, task_list: task_list)
99

1010
task_list = CodeCorpsWeb.TaskListController.preload(task_list)
11-
rendered_json = render(CodeCorpsWeb.TaskListView, "show.json-api", %{data: task_list, conn: %Plug.Conn{}, params: task_list.id})
11+
rendered_json = render(CodeCorpsWeb.TaskListView, "show.json", %{data: task_list, conn: %Plug.Conn{}, params: task_list.id})
1212

1313
expected_json = %{
1414
:data => %{

0 commit comments

Comments
 (0)