Use factories instead of creating models manually
This commit is contained in:
parent
37b63cace2
commit
39fc9f1630
|
|
@ -15,12 +15,14 @@ RSpec.describe StatisticsController, type: :controller do
|
||||||
before do
|
before do
|
||||||
@tournament = create(:group_stage_tournament)
|
@tournament = create(:group_stage_tournament)
|
||||||
@group_stage = @tournament.stages.find_by(level: -1)
|
@group_stage = @tournament.stages.find_by(level: -1)
|
||||||
@most_dominant_score = GroupScore.new team: @tournament.teams.first,
|
@most_dominant_score = create(:group_score,
|
||||||
group_points: 100,
|
team: @tournament.teams.first,
|
||||||
scored_points: 100, received_points: 0
|
group_points: 100,
|
||||||
@least_dominant_score = GroupScore.new team: @tournament.teams.first,
|
scored_points: 100, received_points: 0)
|
||||||
group_points: 0,
|
@least_dominant_score = create(:group_score,
|
||||||
scored_points: 0, received_points: 100
|
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 << @most_dominant_score
|
||||||
@tournament.stages.first.groups.first.group_scores << @least_dominant_score
|
@tournament.stages.first.groups.first.group_scores << @least_dominant_score
|
||||||
@tournament.save!
|
@tournament.save!
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ RSpec.describe StatisticsService do
|
||||||
tournament = create(:tournament)
|
tournament = create(:tournament)
|
||||||
group_stage = create(:group_stage)
|
group_stage = create(:group_stage)
|
||||||
group = group_stage.groups.first
|
group = group_stage.groups.first
|
||||||
@most_dominant_score = GroupScore.new team: create(:team),
|
@most_dominant_score = create(:group_score,
|
||||||
group_points: 100,
|
group_points: 100,
|
||||||
scored_points: 100, received_points: 0
|
scored_points: 100, received_points: 0)
|
||||||
@least_dominant_score = GroupScore.new team: create(:team),
|
@least_dominant_score = create(:group_score,
|
||||||
group_points: 0,
|
group_points: 0,
|
||||||
scored_points: 0, received_points: 100
|
scored_points: 0, received_points: 100)
|
||||||
group.group_scores << @most_dominant_score
|
group.group_scores << @most_dominant_score
|
||||||
group.group_scores << @least_dominant_score
|
group.group_scores << @least_dominant_score
|
||||||
tournament.stages << group_stage
|
tournament.stages << group_stage
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue