fix: sync team action item updates

This commit is contained in:
Daniel Schädler 2026-04-23 09:39:39 +02:00
parent eea065bd75
commit 443b7ff869
2 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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'))