Skip to content

Commit 7d78d1e

Browse files
committed
move fixtures from github_webhooks to test/fixtures for clarity see: #6 (comment)
1 parent d98d532 commit 7d78d1e

7 files changed

+12
-8
lines changed

test/controllers/webhooks_controller_test.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
defmodule Dwylbot.WebhooksControllerTest do
22
use Dwylbot.ConnCase
33
@root_dir File.cwd!
4-
@data_in_progress Path.join(~w(#{@root_dir} github_webhooks dwylbot-test.json))
5-
@data_bug Path.join(~w(#{@root_dir} github_webhooks dwylbot-test-bug-label.json))
4+
@data_in_progress Path.join(~w(#{@root_dir} test/fixtures dwylbot-test.json))
5+
@data_bug Path.join(~w(#{@root_dir} test/fixtures dwylbot-test-bug-label.json))
66

77
test "GET /webhooks", %{conn: conn} do
88
conn = get conn, "/webhooks"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

web/controllers/webhooks_controller.ex

+10-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule Dwylbot.WebhooksController do
77
end
88

99
def create(conn, params) do
10-
IO.inspect params
10+
# IO.inspect params
1111
action = params["action"]
1212
labels = params["issue"]["labels"]
1313
assignees = params["issue"]["assignees"]
@@ -16,13 +16,17 @@ defmodule Dwylbot.WebhooksController do
1616
issue_id = params["issue"]["number"]
1717
sender = params["sender"]["login"]
1818

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

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

0 commit comments

Comments
 (0)