@@ -36,15 +36,9 @@ defmodule AlgoraWeb.Webhooks.GithubControllerTest do
3636
3737 describe "create bounties" do
3838 test "handles bounty command with unauthorized user" , ctx do
39- { :error , :unauthorized } =
40- process_scenario ( ctx , [
41- % {
42- event_action: "issue_comment.created" ,
43- user_type: :unauthorized ,
44- body: "/bounty $100"
45- }
46- ] )
47-
39+ scenario = [ % { event_action: "issue_comment.created" , user_type: :unauthorized , body: "/bounty $100" } ]
40+ { result , _log } = with_log ( fn -> process_scenario ( ctx , scenario ) end )
41+ assert { :error , :unauthorized } = result
4842 assert Repo . aggregate ( Bounty , :count ) == 0
4943 end
5044
@@ -171,14 +165,16 @@ defmodule AlgoraWeb.Webhooks.GithubControllerTest do
171165
172166 describe "create tips" do
173167 test "rejects tip command when user is unauthorized" , ctx do
174- { :error , :unauthorized } =
175- process_scenario ( ctx , [
176- % {
177- event_action: "issue_comment.created" ,
178- user_type: :unauthorized ,
179- body: "/tip $100 @jsmith"
180- }
181- ] )
168+ scenario = [
169+ % {
170+ event_action: "issue_comment.created" ,
171+ user_type: :unauthorized ,
172+ body: "/tip $100 @jsmith"
173+ }
174+ ]
175+
176+ { result , _log } = with_log ( fn -> process_scenario ( ctx , scenario ) end )
177+ assert { :error , :unauthorized } = result
182178
183179 assert [ ] = all_enqueued ( worker: NotifyTipIntent )
184180 end
@@ -985,21 +981,16 @@ defmodule AlgoraWeb.Webhooks.GithubControllerTest do
985981 end
986982
987983 defp process_scenario ( ctx , scenario ) do
988- { result , _log } =
989- with_log ( fn ->
990- Enum . reduce_while (
991- scenario ,
992- :ok ,
993- fn opts , :ok ->
994- case ctx |> Map . merge ( opts ) |> mock_webhook ( ) |> GithubController . process_delivery ( ) do
995- :ok -> { :cont , :ok }
996- error -> { :halt , error }
997- end
998- end
999- )
1000- end )
1001-
1002- result
984+ Enum . reduce_while (
985+ scenario ,
986+ :ok ,
987+ fn opts , :ok ->
988+ case ctx |> Map . merge ( opts ) |> mock_webhook ( ) |> GithubController . process_delivery ( ) do
989+ :ok -> { :cont , :ok }
990+ error -> { :halt , error }
991+ end
992+ end
993+ )
1003994 end
1004995
1005996 defp process_scenario! ( ctx , scenario ) do
0 commit comments