From fbb87f5f7c6e554c1eeb1d24f510ff793ee7ddc0 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Thu, 29 Nov 2018 10:48:26 +0100 Subject: [PATCH] Add a tournament with stages to factory --- spec/factories/tournaments.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/factories/tournaments.rb b/spec/factories/tournaments.rb index 36ae8bc..f3b3f34 100644 --- a/spec/factories/tournaments.rb +++ b/spec/factories/tournaments.rb @@ -5,5 +5,19 @@ FactoryBot.define do name { Faker::Dog.name } description { Faker::Lorem.sentence } user + transient do + teams_count { 16 } + end + after(:create) do |tournament, evaluator| + tournament.teams = create_list(:team, evaluator.teams_count, tournament: tournament) + end + factory :stage_tournament do + transient do + stage_count { 1 } + end + after(:create) do |tournament, evaluator| + tournament.stages = create_list(:stage, evaluator.stage_count) + end + end end end