Skip to content

Commit

Permalink
move fixtures from github_webhooks to test/fixtures for clarity see: #…
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Mar 16, 2017
1 parent d98d532 commit 7d78d1e
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions test/controllers/webhooks_controller_test.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
defmodule Dwylbot.WebhooksControllerTest do
use Dwylbot.ConnCase
@root_dir File.cwd!
@data_in_progress Path.join(~w(#{@root_dir} github_webhooks dwylbot-test.json))
@data_bug Path.join(~w(#{@root_dir} github_webhooks dwylbot-test-bug-label.json))
@data_in_progress Path.join(~w(#{@root_dir} test/fixtures dwylbot-test.json))
@data_bug Path.join(~w(#{@root_dir} test/fixtures dwylbot-test-bug-label.json))

test "GET /webhooks", %{conn: conn} do
conn = get conn, "/webhooks"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 10 additions & 6 deletions web/controllers/webhooks_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Dwylbot.WebhooksController do
end

def create(conn, params) do
IO.inspect params
# IO.inspect params
action = params["action"]
labels = params["issue"]["labels"]
assignees = params["issue"]["assignees"]
Expand All @@ -16,13 +16,17 @@ defmodule Dwylbot.WebhooksController do
issue_id = params["issue"]["number"]
sender = params["sender"]["login"]

invalid = action == "labeled" && contain_label?("in-progress", labels) && Enum.empty?(assignees)
invalid = action == "labeled"
&& contain_label?("in-progress", labels) && Enum.empty?(assignees)

if invalid do
client = Tentacat.Client.new(%{access_token: System.get_env("GITHUB_ACCESS_TOKEN")})
comment_body = %{"body" => "@#{sender} the `in-progress` label has been added to this issue **without an Assignee**.
Please assign a user to this issue before applying the `in-progress` label."}
Tentacat.Issues.Comments.create(owner, repo, issue_id, comment_body, client)
client = Tentacat.Client.new(%{access_token:
System.get_env("GITHUB_ACCESS_TOKEN")})
comment_body = %{"body" => "@#{sender} the `in-progress` label has been
added to this issue **without an Assignee**. Please assign a user to this
issue before applying the `in-progress` label."}
Tentacat.Issues.Comments.create(owner, repo, issue_id,
comment_body, client)
conn
|> put_status(201)
|> json(%{ok: true})
Expand Down

0 comments on commit 7d78d1e

Please sign in to comment.