diff --git a/app/controllers/team_action_items_controller.rb b/app/controllers/team_action_items_controller.rb index 8011ef6..b4f14ee 100644 --- a/app/controllers/team_action_items_controller.rb +++ b/app/controllers/team_action_items_controller.rb @@ -9,6 +9,7 @@ class TeamActionItemsController < ApplicationController # PATCH /team_action_items/1 def update if @team_action_item.update(team_action_item_params) + push_sync_if_needed!(@team_action_item.tournament) render json: @team_action_item else render json: @team_action_item.errors, status: :unprocessable_entity @@ -24,4 +25,8 @@ class TeamActionItemsController < ApplicationController def team_action_item_params params.slice(:completed).permit(:completed) end + + def push_sync_if_needed!(tournament) + TournamentSyncEnqueue.call(tournament) + end end diff --git a/spec/controllers/team_action_items_controller_spec.rb b/spec/controllers/team_action_items_controller_spec.rb index 5eac4ef..efebd7a 100644 --- a/spec/controllers/team_action_items_controller_spec.rb +++ b/spec/controllers/team_action_items_controller_spec.rb @@ -19,6 +19,14 @@ RSpec.describe TeamActionItemsController, type: :controller do expect(team_action_item.completed_at).not_to be_nil end + it 'enqueues tournament sync' do + allow(TournamentSyncEnqueue).to receive(:call) + + patch :update, params: { id: team_action_item.to_param, completed: true } + + expect(TournamentSyncEnqueue).to have_received(:call).with(team_action_item.tournament) + end + it 'can untick item' do team_action_item.update!(completed: true, completed_at: Time.zone.parse('2026-04-22T09:00:00Z'))