Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 7964bb7

Browse files
authored
Update factories (#1039)
This updates the season and project factories to prevent name-collisions (and the risk of flaky specs).
1 parent 1afeb0d commit 7964bb7

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

spec/factories/projects.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,5 @@
3030
trait :in_current_season do
3131
season { Season.current }
3232
end
33-
34-
trait :in_last_season do
35-
season { Season.find_or_create_by name: (Date.today.year - 1) }
36-
end
3733
end
3834
end

spec/factories/season.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
end
55

66
trait :past do
7-
name '2010'
7+
name '1999'
88
end
99
end

spec/models/project_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,26 @@
2323
subject(:selected) { described_class.selected }
2424

2525
let!(:current_season) { Season.current }
26-
let!(:other_season) { create(:season) }
26+
let!(:past_season) { create(:season, :past) }
2727

2828
let!(:project1) { create(:project, season: current_season) }
2929
let!(:project2) { create(:project, :accepted, season: current_season) }
3030
let!(:project3) { create(:project, :accepted, season: current_season) }
3131
let!(:project4) { create(:project, :accepted, season: current_season) }
32-
let!(:project5) { create(:project, :accepted, season: other_season) }
32+
let!(:project5) { create(:project, :accepted, season: past_season) }
3333

3434
before do
3535
create(:team, kind: 'full_time', project: project3, season: current_season)
3636
create(:team, kind: nil, project: project4, season: current_season)
37-
create(:team, kind: 'full_time', project: project5, season: other_season)
37+
create(:team, kind: 'full_time', project: project5, season: past_season)
3838
end
3939

4040
it 'returns only accepted projects with accepted teams' do
4141
expect(selected).to contain_exactly(project3)
4242
end
4343

4444
context 'when passing a specific season' do
45-
subject(:selected) { described_class.selected(season: other_season) }
45+
subject(:selected) { described_class.selected(season: past_season) }
4646

4747
it 'returns only accepted projects with accepted teams from that season' do
4848
expect(selected).to contain_exactly(project5)

0 commit comments

Comments
 (0)