Test if match_score point change triggers group score calculation

This commit is contained in:
Daniel Schädler 2019-06-01 19:35:12 +02:00
parent 79b4008082
commit 23d167e04d
1 changed files with 37 additions and 0 deletions

View File

@ -61,4 +61,41 @@ RSpec.describe MatchScoresController, type: :controller do
end end
end end
end end
describe 'triggers group point calculation' do
before(:each) do
apply_authentication_headers_for @match_score.owner
end
before do
@tournament = create(:group_stage_tournament, stage_count: 0, match_factory: :filled_group_match)
@group = @tournament.stages.first.groups.first
@match_score = @group.matches.first.match_scores.first
expect(UpdateGroupsGroupScoresAndSave).to receive(:call).once.with(group: @group).and_return(context)
end
let(:valid_update) do
{
points: 42
}
end
context 'when successful' do
let(:context) { double(:context, success?: true) }
it 'returns a 200 status code' do
put :update, params: { id: @match_score.to_param }.merge(valid_update)
expect(response).to be_successful
end
end
context 'when unsuccessful' do
let(:context) { double(:context, success?: false) }
it 'returns a 200 status code' do
put :update, params: { id: @match_score.to_param }.merge(valid_update)
expect(response).to be_successful
end
end
end
end end