Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
asummers committed Nov 26, 2017
1 parent a5e50f5 commit 931abeb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/code_corps_web/controllers/github_event_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ defmodule CodeCorpsWeb.GithubEventController do
action = payload |> Map.get("action", "")
event_support =
if should_process?(payload) do
type
|> EventSupport.status(action)
|> process_event(type, delivery_id, payload)
process_status = type |> EventSupport.status(action)
process_status |> process_event(type, delivery_id, payload)
process_status
else
:ignored
end
Expand All @@ -66,7 +66,7 @@ defmodule CodeCorpsWeb.GithubEventController do
where: not(is_nil(repo.project_id))
Repo.one(query) != nil
end
def should_process?(_), do: false
def should_process?(_), do: true

@spec update(Conn.t, map) :: Conn.t
def update(%Conn{} = conn, %{"id" => id} = params) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ defmodule CodeCorpsWeb.GithubEventControllerTest do
test "responds with 200 for a supported event", %{conn: conn} do
path = conn |> github_events_path(:create)
payload = load_event_fixture("installation_created")
insert(:github_repo, github_id: payload["repository"]["id"])
assert conn |> for_event("installation", "foo") |> post(path, payload) |> response(200)

assert Repo.get_by(GithubEvent, github_delivery_id: "foo")
Expand All @@ -111,9 +110,9 @@ defmodule CodeCorpsWeb.GithubEventControllerTest do
@tag :github_webhook
test "responds with 202 for a supported event but no project_id", %{conn: conn} do
path = conn |> github_events_path(:create)
payload = load_event_fixture("installation_created")
payload = load_event_fixture("pull_request_synchronize")
insert(:github_repo, github_id: payload["repository"]["id"], project: nil)
assert conn |> for_event("installation", "foo") |> post(path, payload) |> response(202)
assert conn |> for_event("pull_request", "foo") |> post(path, payload) |> response(202)

refute Repo.get_by(GithubEvent, github_delivery_id: "foo")
end
Expand Down

0 comments on commit 931abeb

Please sign in to comment.