fix: sync team action item updates
This commit is contained in:
parent
eea065bd75
commit
443b7ff869
|
|
@ -9,6 +9,7 @@ class TeamActionItemsController < ApplicationController
|
||||||
# PATCH /team_action_items/1
|
# PATCH /team_action_items/1
|
||||||
def update
|
def update
|
||||||
if @team_action_item.update(team_action_item_params)
|
if @team_action_item.update(team_action_item_params)
|
||||||
|
push_sync_if_needed!(@team_action_item.tournament)
|
||||||
render json: @team_action_item
|
render json: @team_action_item
|
||||||
else
|
else
|
||||||
render json: @team_action_item.errors, status: :unprocessable_entity
|
render json: @team_action_item.errors, status: :unprocessable_entity
|
||||||
|
|
@ -24,4 +25,8 @@ class TeamActionItemsController < ApplicationController
|
||||||
def team_action_item_params
|
def team_action_item_params
|
||||||
params.slice(:completed).permit(:completed)
|
params.slice(:completed).permit(:completed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def push_sync_if_needed!(tournament)
|
||||||
|
TournamentSyncEnqueue.call(tournament)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,14 @@ RSpec.describe TeamActionItemsController, type: :controller do
|
||||||
expect(team_action_item.completed_at).not_to be_nil
|
expect(team_action_item.completed_at).not_to be_nil
|
||||||
end
|
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
|
it 'can untick item' do
|
||||||
team_action_item.update!(completed: true, completed_at: Time.zone.parse('2026-04-22T09:00:00Z'))
|
team_action_item.update!(completed: true, completed_at: Time.zone.parse('2026-04-22T09:00:00Z'))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue