From 0337b6fad8d2b4700eff59810b347b22d37f92d6 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Tue, 14 May 2019 14:57:13 +0200 Subject: [PATCH] Save match_scores after editing them in tests --- spec/controllers/matches_controller_spec.rb | 6 ++++-- spec/services/playoff_stage_service_spec.rb | 11 ++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/spec/controllers/matches_controller_spec.rb b/spec/controllers/matches_controller_spec.rb index 35dd4e0..ee47017 100644 --- a/spec/controllers/matches_controller_spec.rb +++ b/spec/controllers/matches_controller_spec.rb @@ -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 diff --git a/spec/services/playoff_stage_service_spec.rb b/spec/services/playoff_stage_service_spec.rb index a5de8fd..3e8812f 100644 --- a/spec/services/playoff_stage_service_spec.rb +++ b/spec/services/playoff_stage_service_spec.rb @@ -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