Skip to content

Commit

Permalink
Merge pull request #10 from rjsamson/phoenix-12
Browse files Browse the repository at this point in the history
Update to Phoenix 1.2
  • Loading branch information
rjsamson committed Jun 24, 2016
2 parents 97a955d + 1c547a0 commit 05f0a11
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 69 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ addons:
services:
- postgresql
before_script:
- cp config/travis.exs config/test.exs
- MIX_ENV=test mix do ecto.create, ecto.migrate
- MIX_ENV=test mix local.hex --force
- MIX_ENV=test mix deps.get
- MIX_ENV=test mix ecto.create
- MIX_ENV=test mix ecto.migrate
script:
- mix test
after_script:
Expand Down
2 changes: 2 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ config :stackfooter, Stackfooter.Endpoint,
{:_, Plug.Adapters.Cowboy.Handler, {Stackfooter.Endpoint, []}}
]}]]

config :stackfooter, ecto_repos: [Stackfooter.Repo]

# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
Expand Down
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
23 changes: 23 additions & 0 deletions config/travis.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use Mix.Config

# We don't run a server during test. If one is required,
# you can enable the server option below.
config :stackfooter, Stackfooter.Endpoint,
http: [port: 4001],
server: false

# Print only warnings and errors during test
config :logger, level: :warn

# Configure your database
config :stackfooter, Stackfooter.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "",
database: "stackfooter_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox

config :stackfooter, :bootstrap,
default_api_key: "4cy7uf63Lw2Sx6652YmLwBKy662weU4q",
default_account: "admin"
14 changes: 8 additions & 6 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ defmodule Stackfooter.Mixfile do
# Type `mix help compile.app` for more information.
def application do
[mod: {Stackfooter, []},
applications: [:phoenix, :phoenix_html, :cowboy, :logger, :gettext,
:phoenix_ecto, :postgrex, :tzdata, :beaker, :comeonin]]
applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger,
:gettext, :phoenix_ecto, :postgrex, :tzdata, :beaker, :comeonin]]
end

# Specifies which paths to compile per environment.
Expand All @@ -32,15 +32,16 @@ defmodule Stackfooter.Mixfile do
#
# Type `mix help deps` for examples and options.
defp deps do
[{:phoenix, "~> 1.1.6"},
{:phoenix_ecto, "~> 2.0"},
[{:phoenix, "~> 1.2.0"},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_ecto, "~> 3.0-rc"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.3"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:gettext, "~> 0.9"},
{:cowboy, "~> 1.0"},
{:timex, "~> 1.0.0"},
{:beaker, ">= 1.2.0"},
{:beaker, ">= 1.3.0", git: "https://github.com/rjsamson/beaker.git"},
{:excoveralls, "~> 0.4", only: :test},
{:comeonin, "~> 2.0"}]
end
Expand All @@ -53,6 +54,7 @@ defmodule Stackfooter.Mixfile do
# See the documentation for `Mix` for more info on aliases.
defp aliases do
["ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
"ecto.reset": ["ecto.drop", "ecto.setup"]]
"ecto.reset": ["ecto.drop", "ecto.setup"],
"test": ["ecto.create --quite", "ecto.migrate", "test"]]
end
end
21 changes: 11 additions & 10 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
%{"beaker": {:hex, :beaker, "1.2.0", "77b3432c0b7828d6278e052e6d28e02f77c065c7eb4c1abe7db2f9cdbe0a0414", [:mix], [{:phoenix, "~> 1.1", [hex: :phoenix, optional: true]}, {:ecto, "~> 1.1", [hex: :ecto, optional: true]}, {:bureaucrat, "~> 0.1.2", [hex: :bureaucrat, optional: false]}]},
"bureaucrat": {:hex, :bureaucrat, "0.1.2", "43d2873e65369bea2ecb2477ea5b0b460df1f1a7c2e84e289cffeafaef1deac0", [:mix], [{:plug, "~> 0.14 or ~> 1.0", [hex: :plug, optional: false]}]},
%{"beaker": {:git, "https://github.com/rjsamson/beaker.git", "af653bd21a072de2d9f670b590d8b6446487c31e", []},
"bureaucrat": {:hex, :bureaucrat, "0.1.4", "63c955828ba6f47f8978d984031e7a208402f634db899999e12352bb72f21aaf", [:mix], [{:plug, "~> 0.14 or ~> 1.0", [hex: :plug, optional: false]}]},
"certifi": {:hex, :certifi, "0.3.0", "389d4b126a47895fe96d65fcf8681f4d09eca1153dc2243ed6babad0aac1e763", [:rebar3], []},
"combine": {:hex, :combine, "0.7.0", "2ac6ae852a9835fe8189af18121cddd5bed2677f5df706dc0d208af668ab845d", [:mix], []},
"comeonin": {:hex, :comeonin, "2.2.0", "3924d5a2a58fdba5d54a4e404e129da5fe1616241ed5fcfff884a8f98781112d", [:mix, :make, :make], []},
"connection": {:hex, :connection, "1.0.2", "f4a06dd3ecae4141aa66f94ce92ea4c4b8753069472814932f1cadbc3078ab80", [:mix], []},
"connection": {:hex, :connection, "1.0.3", "3145f7416be3df248a4935f24e3221dc467c1e3a158d62015b35bd54da365786", [:mix], []},
"cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:rebar, :make], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.0", [hex: :ranch, optional: false]}]},
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], []},
"db_connection": {:hex, :db_connection, "0.2.1", "8543ec61432c1bca949dbca596271fb3e2029faf2dc580d281e4f404097f0f4c", [:mix], [{:sbroker, "~> 0.7", [hex: :sbroker, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: true]}, {:connection, "~> 1.0.2", [hex: :connection, optional: false]}]},
"decimal": {:hex, :decimal, "1.1.1", "a8ff5b673105e6cdaca96f799aeefc6f07142881b616c65db16e14e556b16e76", [:mix], []},
"ecto": {:hex, :ecto, "1.1.3", "859244ba9b7e10ba18889e48172d6455b552df3f9029bf312bcc7e360e3224de", [:mix], [{:sbroker, "~> 0.7", [hex: :sbroker, optional: true]}, {:postgrex, "~> 0.11.0", [hex: :postgrex, optional: true]}, {:poolboy, "~> 1.4", [hex: :poolboy, optional: false]}, {:poison, "~> 1.0", [hex: :poison, optional: true]}, {:mariaex, "~> 0.5.0", [hex: :mariaex, optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, optional: false]}]},
"db_connection": {:hex, :db_connection, "1.0.0-rc.3", "d9ceb670fe300271140af46d357b669983cd16bc0d01206d7d3222dde56cf038", [:mix], [{:sbroker, "~> 1.0.0-beta.3", [hex: :sbroker, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: true]}, {:connection, "~> 1.0.2", [hex: :connection, optional: false]}]},
"decimal": {:hex, :decimal, "1.1.2", "79a769d4657b2d537b51ef3c02d29ab7141d2b486b516c109642d453ee08e00c", [:mix], []},
"ecto": {:hex, :ecto, "2.0.1", "cf97a4d353e14af3d3cc3b4452cfbd18b3aeee1fb4075475efeccec3853444a9", [:mix], [{:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: true]}, {:sbroker, "~> 1.0-beta", [hex: :sbroker, optional: true]}, {:mariaex, "~> 0.7.7", [hex: :mariaex, optional: true]}, {:postgrex, "~> 0.11.2", [hex: :postgrex, optional: true]}, {:db_connection, "~> 1.0-rc.2", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}]},
"excoveralls": {:hex, :excoveralls, "0.4.6", "022db34cf2470efdbc386f442072e00394a1c21f5fadc6b9bd6084dfdaa55b82", [:mix], [{:hackney, ">= 0.12.0", [hex: :hackney, optional: false]}, {:exjsx, "~> 3.0", [hex: :exjsx, optional: false]}]},
"exjsx": {:hex, :exjsx, "3.2.0", "7136cc739ace295fc74c378f33699e5145bead4fdc1b4799822d0287489136fb", [:mix], [{:jsx, "~> 2.6.2", [hex: :jsx, optional: false]}]},
"fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], []},
Expand All @@ -17,14 +17,15 @@
"idna": {:hex, :idna, "1.0.3", "d456a8761cad91c97e9788c27002eb3b773adaf5c893275fc35ba4e3434bbd9b", [:rebar3], []},
"jsx": {:hex, :jsx, "2.6.2", "213721e058da0587a4bce3cc8a00ff6684ced229c8f9223245c6ff2c88fbaa5a", [:mix, :rebar], []},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []},
"phoenix": {:hex, :phoenix, "1.1.6", "7bf19002669c8f692f5a9c8d30dab7b49f3dc56228d5bde92a12fb426b4783c2", [:mix], [{:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: false]}, {:plug, "~> 1.0", [hex: :plug, optional: false]}, {:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}]},
"phoenix_ecto": {:hex, :phoenix_ecto, "2.0.1", "24532a443b1686150fd14819a4a366eccf41135da2a2ed6ae2f78597828ecb0a", [:mix], [{:poison, "~> 1.3", [hex: :poison, optional: true]}, {:phoenix_html, "~> 2.2", [hex: :phoenix_html, optional: true]}, {:ecto, "~> 1.1.2", [hex: :ecto, optional: false]}]},
"phoenix": {:hex, :phoenix, "1.2.0", "1bdeb99c254f4c534cdf98fd201dede682297ccc62fcac5d57a2627c3b6681fb", [:mix], [{:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: false]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, optional: false]}, {:plug, "~> 1.1", [hex: :plug, optional: false]}, {:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}]},
"phoenix_ecto": {:hex, :phoenix_ecto, "3.0.0", "b947aaf03d076f5b1448f87828f22fb7710478ee38455c67cc3fe8e9a4dfd015", [:mix], [{:ecto, "~> 2.0.0-rc", [hex: :ecto, optional: false]}, {:phoenix_html, "~> 2.6", [hex: :phoenix_html, optional: true]}]},
"phoenix_html": {:hex, :phoenix_html, "2.6.0", "b9f7e091eb3d908586d9634596478fb9e577ee033d76f4ff327a745569bdd2d8", [:mix], [{:plug, "~> 0.13 or ~> 1.0", [hex: :plug, optional: false]}]},
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.0.5", "829218c4152ba1e9848e2bf8e161fcde6b4ec679a516259442561d21fde68d0b", [:mix], [{:phoenix, "~> 1.0 or ~> 1.2-rc", [hex: :phoenix, optional: false]}, {:fs, "~> 0.9.1", [hex: :fs, optional: false]}]},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.0", "c31af4be22afeeebfaf246592778c8c840e5a1ddc7ca87610c41ccfb160c2c57", [:mix], []},
"plug": {:hex, :plug, "1.1.6", "8927e4028433fcb859e000b9389ee9c37c80eb28378eeeea31b0273350bf668b", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}]},
"poison": {:hex, :poison, "1.5.2", "560bdfb7449e3ddd23a096929fb9fc2122f709bcc758b2d5d5a5c7d0ea848910", [:mix], []},
"poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []},
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []},
"postgrex": {:hex, :postgrex, "0.11.0", "ffc900db99742a57f26da3e56c15a6f38bb419f0d627452da82036b6809b6042", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, optional: false]}, {:db_connection, "~> 0.2", [hex: :db_connection, optional: false]}, {:connection, "~> 1.0", [hex: :connection, optional: false]}]},
"postgrex": {:hex, :postgrex, "0.11.2", "139755c1359d3c5c6d6e8b1ea72556d39e2746f61c6ddfb442813c91f53487e8", [:mix], [{:connection, "~> 1.0", [hex: :connection, optional: false]}, {:db_connection, "~> 1.0-rc", [hex: :db_connection, optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, optional: false]}]},
"ranch": {:hex, :ranch, "1.2.1", "a6fb992c10f2187b46ffd17ce398ddf8a54f691b81768f9ef5f461ea7e28c762", [:make], []},
"ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5", "2e73e068cd6393526f9fa6d399353d7c9477d6886ba005f323b592d389fb47be", [:make], []},
"timex": {:hex, :timex, "1.0.0", "c2f4c86c6ec1af5b6614c85b0afa6bd2422f6d72fa3e8ab42baacb801e3235b5", [:mix], [{:tzdata, "== 0.1.8 or ~> 0.5", [hex: :tzdata, optional: false]}, {:combine, "~> 0.7", [hex: :combine, optional: false]}]},
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
Loading

0 comments on commit 05f0a11

Please sign in to comment.