-
Notifications
You must be signed in to change notification settings - Fork 86
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
Refactor Role Skills Controller Tests #416
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me 👍. Nice work!
379234e
to
eab4979
Compare
json = conn |> get(path) |> json_response(200) | ||
assert json["data"] == [] | ||
conn = conn |> get(path) | ||
assert json_response(conn, 200)["data"] == [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep this roughly as it is in some of the closed PRs. conn |> get(path) |> json_response(200)
, then assign the response and assert against that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this okay instead? i didn't realize there was a request_index function to help with that until just now.
describe "index" do
test "lists all entries on index", %{conn: conn} do
[project_skill_1, project_skill_2] = insert_pair(:project_skill)
conn
|> request_index
|> json_response(200)
|> assert_ids_from_response([project_skill_1.id, project_skill_2.id])
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize that either.
@@ -87,62 +46,44 @@ defmodule CodeCorps.RoleSkillControllerTest do | |||
role = insert(:role, name: "Frontend Developer") | |||
skill = insert(:skill, title: "test skill") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to the attributes here. Just insert(:role)
will work.
conn | ||
|> request_index | ||
|> json_response(200) | ||
|> assert_ids_from_response([role_skill_1.id, role_skill_2.id]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing here is weird. There are three spaces.
conn | ||
|> get(path) | ||
|> json_response(200) | ||
|> assert_ids_from_response([role_skill_1.id, role_skill_2.id]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might use that request_index
helper instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That created identical tests for listing all the entries on the index and filtering the index...hm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filter test should have a third item that's not included in the ids from response...maybe I should put that back in to test the filtering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amyschools yes, absolutely.
role_skill_1 = insert(:role_skill, role: role, skill: elixir) | ||
role_skill_2 = insert(:role_skill, role: role, skill: phoenix) | ||
insert(:role_skill, role: role, skill: rails) | ||
[role_skill_1, role_skill_2] = insert_pair(:role_skill) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You figured out the missing third record, so I'll just link https://github.com/code-corps/code-corps-api/pull/425/files#r86388037 as a pointer on how to write this in one line.
04271fa
to
d235101
Compare
d235101
to
9b60645
Compare
What's in this PR?
Adding helpers from api_case.ex.
References
Fixes #414
Progress on: #413