@@ -36,9 +36,15 @@ defmodule AlgoraWeb.Webhooks.GithubControllerTest do
3636
3737 describe "create bounties" do
3838 test "handles bounty command with unauthorized user" , ctx do
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
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+
4248 assert Repo . aggregate ( Bounty , :count ) == 0
4349 end
4450
@@ -165,16 +171,14 @@ defmodule AlgoraWeb.Webhooks.GithubControllerTest do
165171
166172 describe "create tips" do
167173 test "rejects tip command when user is unauthorized" , ctx do
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
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+ ] )
178182
179183 assert [ ] = all_enqueued ( worker: NotifyTipIntent )
180184 end
@@ -981,16 +985,21 @@ defmodule AlgoraWeb.Webhooks.GithubControllerTest do
981985 end
982986
983987 defp process_scenario ( ctx , scenario ) do
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- )
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
9941003 end
9951004
9961005 defp process_scenario! ( ctx , scenario ) do
0 commit comments