Skip to content

Commit

Permalink
Run mix format
Browse files Browse the repository at this point in the history
  • Loading branch information
taneliang committed Aug 14, 2018
1 parent e3ecfc8 commit 397529e
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 45 deletions.
5 changes: 2 additions & 3 deletions api/sync/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ config :sync, SyncWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: "/uUqYxkh/lkAVm4auwGYU+nbQO9gh8NZVZtnQ5OvPGJq4aQBGkhYk65aRzCiEWVW",
render_errors: [view: SyncWeb.ErrorView, accepts: ~w(html json)],
pubsub: [name: Sync.PubSub,
adapter: Phoenix.PubSub.PG2]
pubsub: [name: Sync.PubSub, adapter: Phoenix.PubSub.PG2]

# Configures Elixir's Logger
config :logger, :console,
Expand All @@ -24,4 +23,4 @@ config :logger, :console,

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env}.exs"
import_config "#{Mix.env()}.exs"
2 changes: 1 addition & 1 deletion api/sync/lib/sync/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Sync.Application do
# Start the Ecto repository
supervisor(Sync.Repo, []),
# Start the endpoint when the application starts
supervisor(SyncWeb.Endpoint, []),
supervisor(SyncWeb.Endpoint, [])
# Start your own worker by calling: Sync.Worker.start_link(arg1, arg2, arg3)
# worker(Sync.Worker, [arg1, arg2, arg3]),
]
Expand Down
5 changes: 3 additions & 2 deletions api/sync/lib/sync_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ defmodule SyncWeb do

def view do
quote do
use Phoenix.View, root: "lib/sync_web/templates",
namespace: SyncWeb
use Phoenix.View,
root: "lib/sync_web/templates",
namespace: SyncWeb

# Import convenience functions from controllers
import Phoenix.Controller, only: [get_flash: 2, view_module: 1]
Expand Down
2 changes: 1 addition & 1 deletion api/sync/lib/sync_web/channels/user_socket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule SyncWeb.UserSocket do
# channel "room:*", SyncWeb.RoomChannel

## Transports
transport :websocket, Phoenix.Transports.WebSocket
transport(:websocket, Phoenix.Transports.WebSocket)
# transport :longpoll, Phoenix.Transports.LongPoll

# Socket params are passed from the client and can
Expand Down
2 changes: 1 addition & 1 deletion api/sync/lib/sync_web/controllers/page_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ defmodule SyncWeb.PageController do
use SyncWeb, :controller

def index(conn, _params) do
render conn, "index.html"
render(conn, "index.html")
end
end
29 changes: 17 additions & 12 deletions api/sync/lib/sync_web/endpoint.ex
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
defmodule SyncWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :sync

socket "/socket", SyncWeb.UserSocket
socket("/socket", SyncWeb.UserSocket)

# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phoenix.digest
# when deploying your static files in production.
plug Plug.Static,
at: "/", from: :sync, gzip: false,
plug(Plug.Static,
at: "/",
from: :sync,
gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
)

# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
if code_reloading? do
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
plug Phoenix.LiveReloader
plug Phoenix.CodeReloader
socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket)
plug(Phoenix.LiveReloader)
plug(Phoenix.CodeReloader)
end

plug Plug.Logger
plug(Plug.Logger)

plug Plug.Parsers,
plug(Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Poison
)

plug Plug.MethodOverride
plug Plug.Head
plug(Plug.MethodOverride)
plug(Plug.Head)

# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
plug Plug.Session,
plug(Plug.Session,
store: :cookie,
key: "_sync_key",
signing_salt: "JcSaVNTL"
)

plug SyncWeb.Router
plug(SyncWeb.Router)

@doc """
Callback invoked for dynamically configuring the endpoint.
Expand Down
17 changes: 9 additions & 8 deletions api/sync/lib/sync_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ defmodule SyncWeb.Router do
use SyncWeb, :router

pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug(:accepts, ["html"])
plug(:fetch_session)
plug(:fetch_flash)
plug(:protect_from_forgery)
plug(:put_secure_browser_headers)
end

pipeline :api do
plug :accepts, ["json"]
plug(:accepts, ["json"])
end

scope "/", SyncWeb do
pipe_through :browser # Use the default browser stack
# Use the default browser stack
pipe_through(:browser)

get "/", PageController, :index
get("/", PageController, :index)
end

# Other scopes may use custom stacks.
Expand Down
4 changes: 2 additions & 2 deletions api/sync/lib/sync_web/views/error_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ defmodule SyncWeb.ErrorHelpers do
Generates tag for inlined form input errors.
"""
def error_tag(form, field) do
Enum.map(Keyword.get_values(form.errors, field), fn (error) ->
content_tag :span, translate_error(error), class: "help-block"
Enum.map(Keyword.get_values(form.errors, field), fn error ->
content_tag(:span, translate_error(error), class: "help-block")
end)
end

Expand Down
10 changes: 5 additions & 5 deletions api/sync/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ defmodule Sync.Mixfile do
app: :sync,
version: "0.0.1",
elixir: "~> 1.4",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
start_permanent: Mix.env == :prod,
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps()
]
Expand All @@ -26,7 +26,7 @@ defmodule Sync.Mixfile do

# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
defp elixirc_paths(_), do: ["lib"]

# Specifies your project dependencies.
#
Expand Down Expand Up @@ -54,7 +54,7 @@ defmodule Sync.Mixfile do
[
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
"ecto.reset": ["ecto.drop", "ecto.setup"],
"test": ["ecto.create --quiet", "ecto.migrate", "test"]
test: ["ecto.create --quiet", "ecto.migrate", "test"]
]
end
end
4 changes: 2 additions & 2 deletions api/sync/test/support/channel_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ defmodule SyncWeb.ChannelCase do
end
end


setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Sync.Repo)

unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(Sync.Repo, {:shared, self()})
end

:ok
end

end
4 changes: 2 additions & 2 deletions api/sync/test/support/conn_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ defmodule SyncWeb.ConnCase do
end
end


setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Sync.Repo)

unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(Sync.Repo, {:shared, self()})
end

{:ok, conn: Phoenix.ConnTest.build_conn()}
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule SyncWeb.PageControllerTest do
use SyncWeb.ConnCase

test "GET /", %{conn: conn} do
conn = get conn, "/"
conn = get(conn, "/")
assert html_response(conn, 200) =~ "Welcome to Phoenix!"
end
end
6 changes: 2 additions & 4 deletions api/sync/test/sync_web/views/error_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ defmodule SyncWeb.ErrorViewTest do
import Phoenix.View

test "renders 404.html" do
assert render_to_string(SyncWeb.ErrorView, "404.html", []) ==
"Not Found"
assert render_to_string(SyncWeb.ErrorView, "404.html", []) == "Not Found"
end

test "renders 500.html" do
assert render_to_string(SyncWeb.ErrorView, "500.html", []) ==
"Internal Server Error"
assert render_to_string(SyncWeb.ErrorView, "500.html", []) == "Internal Server Error"
end
end
1 change: 0 additions & 1 deletion api/sync/test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ExUnit.start()

Ecto.Adapters.SQL.Sandbox.mode(Sync.Repo, :manual)

0 comments on commit 397529e

Please sign in to comment.