Use factories instead of creating models manually

This commit is contained in:
Thor77 2019-05-15 11:59:28 +02:00
parent 37b63cace2
commit 39fc9f1630
No known key found for this signature in database
GPG Key ID: 5051E71B46AA669A
2 changed files with 14 additions and 12 deletions

View File

@ -15,12 +15,14 @@ RSpec.describe StatisticsController, type: :controller do
before do
@tournament = create(:group_stage_tournament)
@group_stage = @tournament.stages.find_by(level: -1)
@most_dominant_score = GroupScore.new team: @tournament.teams.first,
group_points: 100,
scored_points: 100, received_points: 0
@least_dominant_score = GroupScore.new team: @tournament.teams.first,
group_points: 0,
scored_points: 0, received_points: 100
@most_dominant_score = create(:group_score,
team: @tournament.teams.first,
group_points: 100,
scored_points: 100, received_points: 0)
@least_dominant_score = create(:group_score,
team: @tournament.teams.first,
group_points: 0,
scored_points: 0, received_points: 100)
@tournament.stages.first.groups.first.group_scores << @most_dominant_score
@tournament.stages.first.groups.first.group_scores << @least_dominant_score
@tournament.save!

View File

@ -6,12 +6,12 @@ RSpec.describe StatisticsService do
tournament = create(:tournament)
group_stage = create(:group_stage)
group = group_stage.groups.first
@most_dominant_score = GroupScore.new team: create(:team),
group_points: 100,
scored_points: 100, received_points: 0
@least_dominant_score = GroupScore.new team: create(:team),
group_points: 0,
scored_points: 0, received_points: 100
@most_dominant_score = create(:group_score,
group_points: 100,
scored_points: 100, received_points: 0)
@least_dominant_score = create(:group_score,
group_points: 0,
scored_points: 0, received_points: 100)
group.group_scores << @most_dominant_score
group.group_scores << @least_dominant_score
tournament.stages << group_stage