diff --git a/slack-gamebot/api/presenters/status_presenter.rb b/slack-gamebot/api/presenters/status_presenter.rb index 09b1382..d7b0cf5 100644 --- a/slack-gamebot/api/presenters/status_presenter.rb +++ b/slack-gamebot/api/presenters/status_presenter.rb @@ -27,7 +27,7 @@ def games h[game.name][:matches_count] = game.matches.count h[game.name][:seasons_count] = game.seasons.count team = game.teams.active.asc(:_id).first - h[game.name][:ping] = team.ping! if team + h[game.name][:ping] = team.ping_if_active! if team end end diff --git a/spec/api/endpoints/status_endpoint_spec.rb b/spec/api/endpoints/status_endpoint_spec.rb index 039cb6f..e723498 100644 --- a/spec/api/endpoints/status_endpoint_spec.rb +++ b/spec/api/endpoints/status_endpoint_spec.rb @@ -25,6 +25,22 @@ end end + context 'with a team that has an inactive account' do + let!(:team) { Fabricate(:team, api: true, active: true) } + before do + expect_any_instance_of(Team).to receive(:ping!) { raise Slack::Web::Api::Errors::SlackError, 'account_inactive' } + end + it 'returns a status and deactivates team' do + status = client.status + expect(status.games_count).to eq 1 + game = status.games[team.game.name] + expect(game['teams_count']).to eq 1 + expect(game['active_teams_count']).to eq 1 + expect(game['api_teams_count']).to eq 1 + expect(team.reload.active).to be false + end + end + context 'with a team with api off' do let!(:team) { Fabricate(:team, api: false) } it 'returns total counts anyway' do