Save match_scores after editing them in tests

This commit is contained in:
Daniel Schädler 2019-05-14 14:57:13 +02:00
parent d0d38a7972
commit 0337b6fad8
2 changed files with 12 additions and 5 deletions

View File

@ -80,8 +80,10 @@ RSpec.describe MatchesController, type: :controller do
context 'stops the match' do
before do
@running_playoff_match.match_scores.each_with_index { |ms, i| ms.points = i }
@running_playoff_match.save
@running_playoff_match.match_scores.each_with_index do |ms, i|
ms.points = i
ms.save
end
put :update, params: { id: @running_playoff_match.to_param }.merge(finished)
@running_playoff_match.reload
end

View File

@ -86,11 +86,16 @@ RSpec.describe PlayoffStageService do
@tournament = create(:stage_tournament, stage_count: 2)
@match = @tournament.stages.find { |s| s.level == 2 }.matches.first
@match.state = :finished
@match.match_scores.each_with_index { |ms, i| ms.points = i }
@match.match_scores.each_with_index do |ms, i|
ms.points = i
ms.save
end
@match.save
@companion_match = @tournament.stages.find { |s| s.level == 2 }.matches.second
@companion_match.match_scores.each_with_index { |ms, i| ms.points = i }
@companion_match.save
@companion_match.match_scores.each_with_index do |ms, i|
ms.points = i
ms.save
end
@match_to_find = @tournament.stages.find { |s| s.level == 1 }.matches.first
end