From e25292ea96500fbb06220972e5efa97971a945b4 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Mon, 27 May 2019 23:25:02 +0200 Subject: [PATCH] Add method to check if match_score is part of a group match --- app/models/match_score.rb | 4 ++++ spec/models/match_score_spec.rb | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/app/models/match_score.rb b/app/models/match_score.rb index b2a3f0c..5bf815a 100644 --- a/app/models/match_score.rb +++ b/app/models/match_score.rb @@ -5,4 +5,8 @@ class MatchScore < ApplicationRecord belongs_to :team delegate :owner, to: :match + + def part_of_group_match? + match.group_match? + end end diff --git a/spec/models/match_score_spec.rb b/spec/models/match_score_spec.rb index b6f7bfc..bff5d5a 100644 --- a/spec/models/match_score_spec.rb +++ b/spec/models/match_score_spec.rb @@ -7,4 +7,14 @@ RSpec.describe MatchScore, type: :model do it { should belong_to :match } it { should belong_to :team } end + + describe '#part_of_group_match?' do + it 'is part of a group match' do + expect(create(:running_group_match).match_scores.first.part_of_group_match?).to be(true) + end + + it 'isn\'t part of a group match' do + expect(create(:running_playoff_match).match_scores.first.part_of_group_match?).to be(false) + end + end end