Skip to content

Commit

Permalink
fixed skill controller test back to how it should be
Browse files Browse the repository at this point in the history
  • Loading branch information
mackenziehicks committed Nov 7, 2016
1 parent 60c8438 commit e6adb2c
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions test/controllers/skill_controller_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule CodeCorps.SkillControllerTest do
use CodeCorps.ApiCase
use CodeCorps.ApiCase, resource_name: :skill

@valid_attrs %{
description: "Elixir is a functional, concurrent, general-purpose programming language that runs on the Erlang virtual machine (BEAM).",
Expand All @@ -10,28 +10,23 @@ defmodule CodeCorps.SkillControllerTest do

describe "index" do
test "lists all entries on index", %{conn: conn} do
path = conn |> skill_path(:index)
json = conn |> get(path) |> json_response(200)
[skill_1, skill_2] = insert_pair(:skill)

assert json["data"] == []
conn
|> request_index
|> json_response(200)
|> assert_ids_from_response([skill_1.id, skill_2.id])
end

test "filters resources on index", %{conn: conn} do
elixir = insert(:skill, title: "Elixir")
phoenix = insert(:skill, title: "Phoenix")
insert(:skill, title: "Rails")
[skill_1, skill_2 | _] = insert_list(3, :skill)

params = %{"filter" => %{"id" => "#{elixir.id},#{phoenix.id}"}}
path = conn |> skill_path(:index, params)

json = conn |> get(path) |> json_response(200)
path = "skills/?filter[id]=#{skill_1.id},#{skill_2.id}"

data = json["data"]
assert data |> length == 2

[first_result, second_result | _] = data
assert first_result["id"] == "#{elixir.id}"
assert second_result["id"] == "#{phoenix.id}"
conn
|> get(path)
|> json_response(200)
|> assert_ids_from_response([skill_1.id, skill_2.id])
end

test "returns search results on index", %{conn: conn} do
Expand Down

0 comments on commit e6adb2c

Please sign in to comment.