Skip to content

Commit

Permalink
Merge pull request #218 from dwyl/add-seed-instructions
Browse files Browse the repository at this point in the history
Adds seed instructions
  • Loading branch information
Cleop authored Sep 7, 2017
2 parents 172d73e + 65f252b commit 1eea3c5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ erl_crash.dump

env.sh
cover
*.env
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ export SECRET_KEY_BASE=<secret_key_base>
export GITHUB_CLIENT_ID=<github_client_id>
export GITHUB_CLIENT_SECRET=<github_client_secret>
export GITHUB_ACCESS_TOKEN=<github_access_token>
export HOOK_ENDPOINT=<hook_endpoint>
```

To start the app:

* Install dependencies with `mix deps.get`
* Create and migrate your database with `mix ecto.create && mix ecto.migrate`
* Install Node.js dependencies with `npm install`
* Seed the database with `mix run priv/repo/seeds.exs`
* Start Phoenix endpoint with `mix phoenix.server`

NB. if you get errors here, please see if this helps: https://github.com/dwyl/learn-phoenix-framework/issues/53
Expand Down
1 change: 0 additions & 1 deletion priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ GithubApi.get_repos("dwyl")
|> Issue.changeset(issue)
|> Repo.insert!
end)

9 changes: 8 additions & 1 deletion test/github/github_api_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule Tudo.GithubApiTest do
test "post!" do
actual = GithubApi.post! "/", %{key: "val"}
expected = %{"method" => "post", "key" => "val"}

assert actual == expected
end

Expand Down Expand Up @@ -89,4 +89,11 @@ defmodule Tudo.GithubApiTest do

assert actual == expected
end

test "decode!" do
actual = GithubApi.decode! ""
expected = %{}

assert actual == expected
end
end
9 changes: 6 additions & 3 deletions web/github/github_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ defmodule Tudo.GithubApi do
[connect_timeout: 1_000_000,
recv_timeout: 1_000_000,
timeout: 1_000_000])
|> Map.fetch!(:body)
|> Poison.decode!
end
|> Map.get(:body, "{}")
|> decode!
end

def decode!(""), do: decode! "{}"
def decode!(str), do: Poison.decode! str

@doc"""
Gets all repos for an org, takes an :org string
Expand Down

0 comments on commit 1eea3c5

Please sign in to comment.