Skip to content
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

clean code and initialise dwylbot github app #53

Merged
merged 1 commit into from
Jun 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,11 @@ Clone the GitHub repo _to your personal computer_:
git clone [email protected]:dwyl/dwylbot.git && cd dwylbot
```

#### Create an Application on GitHub
#### Create a GitHub Application

If you don't already have a GitHub application with valid
keys you can use to run this project on your localhost,
please follow these instructions:
https://github.com/dwyl/hapi-auth-github/blob/master/GITHUB-APP-STEP-BY-STEP-GUIDE.md
please follow these instructions: https://developer.github.com/apps

#### Define Local Environment Variables

Expand All @@ -115,7 +114,6 @@ create an `.env` file where you can define your environment variables.
```
export GITHUB_CLIENT_ID=FollowTheInstructionsToCreateAnAppOnGitHub
export GITHUB_CLIENT_SECRET=*******
export GITHUB_ACCESS_TOKEN=******
export DATABASE_URL=****
# SECRET_KEY_BASE is required for Auth Cookie:
export SECRET_KEY_BASE=MustBeA64ByteStringProbablyBestToGenerateUsingCryptoOrJustUseThisWithSomeRandomDigitsOnTheEnd1234567890
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Dwylbot.Mixfile do
def project do
[app: :dwylbot,
version: "0.0.1",
elixir: "~> 1.3.1",
elixir: "~> 1.3",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
test_coverage: [tool: ExCoveralls],
Expand Down
25 changes: 25 additions & 0 deletions test/controllers/installation_controller_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
defmodule Dwylbot.InstallationControllerTest do
use Dwylbot.ConnCase

setup %{conn: conn} = config do
if name = config[:login_as] do
user = %{username: name}
conn = assign(conn, :user, user)
{:ok, conn: conn, user: user}
else
:ok
end
end

test "GET /installation - redirect to home page not logged in", %{conn: conn} do
conn = get conn, "/installation"
assert html_response(conn, 302) =~ "redirect"
end

@tag login_as: "Simon"
test "GET /installation - list dwylbot installation", %{conn: conn} do
conn = get conn, "/installation"
assert html_response(conn, 200) =~ "List of dwylbot installations"
end

end
9 changes: 0 additions & 9 deletions test/controllers/repo_controller_test.exs

This file was deleted.

22 changes: 0 additions & 22 deletions test/controllers/webhooks_controller_test.exs

This file was deleted.

9 changes: 9 additions & 0 deletions web/controllers/installation_controller.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Dwylbot.InstallationController do
use Dwylbot.Web, :controller

plug :authenticate_user when action in [:index]

def index(conn, _params) do
render conn, "index.html"
end
end
19 changes: 0 additions & 19 deletions web/controllers/repo_controller.ex

This file was deleted.

41 changes: 0 additions & 41 deletions web/controllers/webhooks_controller.ex

This file was deleted.

8 changes: 1 addition & 7 deletions web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ defmodule Dwylbot.Router do
pipe_through :browser

get "/", PageController, :index
get "/repo", RepoController, :index
get "/repo/hooks", RepoController, :hooks
end

scope "/webhooks", Dwylbot do
pipe_through :api
post "/create", WebhooksController, :create
get "/installation", InstallationController, :index
end

scope "/auth", Dwylbot do
Expand Down
2 changes: 2 additions & 0 deletions web/templates/installation/index.html.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>List of dwylbot installations</h1>
<p>coming soon!</p>
2 changes: 1 addition & 1 deletion web/templates/page/index.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ so everyone can communicate better and work as a team.<br />
<div class="jumbotron">
<h2>Welcome <%= @current_user.username %>!</h2>

<%= link "Add Dwylbot on your repositories", to: repo_path(@conn, :index), class: "btn btn-primary" %>
<%= link "See your dwylbot installations", to: installation_path(@conn, :index), class: "btn btn-primary" %>
<%= link "Logout", to: auth_path(@conn, :delete), method: :delete, class: "btn btn-danger" %>
</div>
<% else %>
Expand Down
1 change: 0 additions & 1 deletion web/templates/repo/hooks.html.eex

This file was deleted.

6 changes: 0 additions & 6 deletions web/templates/repo/index.html.eex

This file was deleted.

3 changes: 3 additions & 0 deletions web/views/installation_view.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule Dwylbot.InstallationView do
use Dwylbot.Web, :view
end
3 changes: 0 additions & 3 deletions web/views/repo_view.ex

This file was deleted.