From 931abeb6e9b67f0a1bcfb1ea82d5fbd677e27a3d Mon Sep 17 00:00:00 2001 From: Andrew Summers Date: Sun, 26 Nov 2017 18:54:09 -0500 Subject: [PATCH] Fix tests. --- lib/code_corps_web/controllers/github_event_controller.ex | 8 ++++---- .../controllers/github_event_controller_test.exs | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/code_corps_web/controllers/github_event_controller.ex b/lib/code_corps_web/controllers/github_event_controller.ex index fee64cc50..cc5b79a3f 100644 --- a/lib/code_corps_web/controllers/github_event_controller.ex +++ b/lib/code_corps_web/controllers/github_event_controller.ex @@ -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 @@ -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 diff --git a/test/lib/code_corps_web/controllers/github_event_controller_test.exs b/test/lib/code_corps_web/controllers/github_event_controller_test.exs index 1e4557a13..559e8606c 100644 --- a/test/lib/code_corps_web/controllers/github_event_controller_test.exs +++ b/test/lib/code_corps_web/controllers/github_event_controller_test.exs @@ -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") @@ -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