@@ -33,7 +33,8 @@ def game_read_model
3333 id : game_id ,
3434 slack_token : game_slack_token ,
3535 slack_channel : game_slack_channel ,
36- ip_address : game_ip_address
36+ ip_address : game_ip_address ,
37+ name : "Arkency 135"
3738 )
3839 end
3940
@@ -48,7 +49,7 @@ def given(*domain_events)
4849 . with (
4950 body : {
5051 "channel" => "#arkency58" ,
51- "text" => "Game Turn 1 <!channel>\n steam://run/8930/q/%2Bconnect%2010.4.0.28"
52+ "text" => "Game Arkency 135 Turn 1 <!channel>\n steam://run/8930/q/%2Bconnect%2010.4.0.28"
5253 } ,
5354 headers : {
5455 "Authorization" => "Bearer xoxb-302139800755-nR1O848GLyVS5ZfNNMpBLm0b" ,
@@ -153,5 +154,36 @@ def given(*domain_events)
153154 expect ( stub0 ) . to have_been_requested
154155 expect ( stub1 ) . to have_been_requested
155156 end
157+
158+ specify ( "timer reset notification" ) do
159+ player_1 = Player . create! ( steam_name : "some_player" , slack_name : "slack_user" )
160+ game = game_read_model
161+ game . update! ( registered_slots : { 1 => player_1 . id } )
162+
163+ stub = stub_request ( :post , "https://slack.com/api/chat.postMessage" )
164+ . with (
165+ body : {
166+ "channel" => "#arkency58" ,
167+ "text" => "The turn timer for game Arkency 135 has been reset by slack_user"
168+ } ,
169+ headers : {
170+ "Authorization" => "Bearer xoxb-302139800755-nR1O848GLyVS5ZfNNMpBLm0b" ,
171+ "Accept" => "application/json; charset=utf-8" ,
172+ "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" ,
173+ "Content-Type" => "application/json"
174+ }
175+ )
176+ . to_return ( status : 200 , body : { ok : true } . to_json , headers : { } )
177+
178+ given (
179+ Game ::GameHosted . new ( data : { turn_timer : 24 . hours . to_i , game_id : game_id } ) ,
180+ Game ::PlayerRegistered . new ( data : { slot_id : 1 , player_id : player_1 . id } ) ,
181+ Game ::PlayerRegistered . new ( data : { slot_id : 2 , player_id : player_2 } ) ,
182+ Game ::PlayerRegistered . new ( data : { slot_id : 3 , player_id : player_3 } ) ,
183+ Game ::NewTurnStarted . new ( data : { turn : 1 } ) ,
184+ Game ::TimerReset . new ( data : { slot : 1 , game_id : game_id } ) ,
185+ )
186+ expect ( stub ) . to have_been_requested
187+ end
156188 end
157189end
0 commit comments