Skip to content

Commit

Permalink
Phoenix 1.2, tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
rjsamson committed Jun 23, 2016
1 parent 8f3d55d commit 98e196a
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 56 deletions.
2 changes: 0 additions & 2 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ config :logger, level: :warn
# Configure your database
config :stackfooter, Stackfooter.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
database: "stackfooter_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox
Expand Down
6 changes: 3 additions & 3 deletions test/controllers/admin_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule Stackfooter.AdminControllerTest do
end

test "resets a venue" do
conn = put_req_header(conn(), "x-starfighter-authorization", @admin_apikey)
conn = put_req_header(build_conn(), "x-starfighter-authorization", @admin_apikey)
|> post("/ob/api/admin/reset/obex")

resp = json_response(conn, 200)
Expand All @@ -41,7 +41,7 @@ defmodule Stackfooter.AdminControllerTest do
end

test "only admin account can perform admin actions" do
conn = put_req_header(conn(), "x-starfighter-authorization", @non_admin_apikey)
conn = put_req_header(build_conn(), "x-starfighter-authorization", @non_admin_apikey)
|> post("/ob/api/admin/reset/obex")

resp = json_response(conn, 401)
Expand All @@ -52,7 +52,7 @@ defmodule Stackfooter.AdminControllerTest do
end

test "errors properly when a venue does not exist" do
conn = put_req_header(conn(), "x-starfighter-authorization", @admin_apikey)
conn = put_req_header(build_conn(), "x-starfighter-authorization", @admin_apikey)
|> post("/ob/api/admin/reset/notavenue")

resp = json_response(conn, 404)
Expand Down
12 changes: 6 additions & 6 deletions test/controllers/score_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ defmodule Stackfooter.ScoreControllerTest do
scores = [%{"cash" => 1176, "name" => "A", "nav" => 1176, "positions" => [%{"price" => 4225, "qty" => 0, "stock" => "NYC"}]},
%{"cash" => -1176, "name" => "RJSA", "nav" => -1176, "positions" => [%{"price" => 4225, "qty" => 0, "stock" => "NYC"}]}]

conn = get(conn(), "/ob/api/scores")
conn = get(build_conn(), "/ob/api/scores")
resp = json_response(conn, 200)

assert resp
Expand All @@ -52,7 +52,7 @@ defmodule Stackfooter.ScoreControllerTest do
end

test "returns the correct score for an individual user" do
conn = put_req_header(conn(), "x-starfighter-authorization", @admin_apikey)
conn = put_req_header(build_conn(), "x-starfighter-authorization", @admin_apikey)
|> get("/ob/api/scores/admin")
resp = json_response(conn, 200)

Expand All @@ -64,7 +64,7 @@ defmodule Stackfooter.ScoreControllerTest do
end

test "all scores route is unauthenticated" do
conn = get(conn(), "/ob/api/scores")
conn = get(build_conn(), "/ob/api/scores")

resp = json_response(conn, 200)

Expand All @@ -73,22 +73,22 @@ defmodule Stackfooter.ScoreControllerTest do
end

test "individual scores route is authenticated" do
conn = put_req_header(conn(), "x-starfighter-authorization", @admin_apikey)
conn = put_req_header(build_conn(), "x-starfighter-authorization", @admin_apikey)
|> get("/ob/api/scores/admin")

resp = json_response(conn, 200)

assert resp
assert resp["ok"]

conn = get(conn(), "/ob/api/scores/admin")
conn = get(build_conn(), "/ob/api/scores/admin")

resp = json_response(conn, 401)

assert resp
refute resp["ok"]

conn = put_req_header(conn(), "x-starfighter-authorization", @non_admin_apikey)
conn = put_req_header(build_conn(), "x-starfighter-authorization", @non_admin_apikey)
|> get("/ob/api/scores/admin")

resp = json_response(conn, 401)
Expand Down

0 comments on commit 98e196a

Please sign in to comment.