Skip to content

Commit 1db8b4c

Browse files
authored
Merge pull request #2266 from davidmillen50/reduce-fabricator-usage
Chore: reduce test suite run time by reducing test data fabrication
2 parents a5a1604 + f693339 commit 1db8b4c

19 files changed

+62
-62
lines changed

spec/features/admin/filtering_sponsors_list_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
end
77

88
describe 'when visiting the sponsors page' do
9-
let!(:sponsors) { Fabricate.times(4, :sponsor_with_contacts) }
9+
let!(:sponsors) { Fabricate.times(2, :sponsor_with_contacts) }
1010

1111
before(:each) do
1212
visit admin_sponsors_path
1313
end
1414

1515
scenario 'all the sponsors are displayed' do
16-
expect(page).to have_css('.sponsor', count: 4)
16+
expect(page).to have_css('.sponsor', count: 2)
1717
end
1818

1919
describe 'when filtering by name' do

spec/features/admin/meeting_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
let(:meeting) { Fabricate(:meeting) }
6868

6969
scenario 'when format: :text' do
70-
invitations = Fabricate.times(4, :attending_meeting_invitation, meeting: meeting)
70+
invitations = Fabricate.times(2, :attending_meeting_invitation, meeting: meeting)
7171
visit attendees_emails_admin_meeting_path(meeting, format: :text)
7272

7373
invitations.each do |invitation|

spec/features/admin/sponsor_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
Fabricate(:workshop_sponsor, sponsor: sponsor)
3535
# Multiple works with the same sponsor and chapter
3636
chapter = Fabricate(:chapter)
37-
5.times do
37+
2.times do
3838
Fabricate(:workshop_sponsor, sponsor: sponsor2, workshop: Fabricate(:workshop_no_sponsor, chapter: chapter))
3939
end
4040

spec/features/admin/workshops_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
context '#views' do
1212
scenario 'list of all chapter workshops' do
13-
workshops = Fabricate.times(5, :workshop, chapter: chapter)
13+
workshops = Fabricate.times(2, :workshop, chapter: chapter)
1414
visit admin_chapter_workshops_path(chapter)
1515

1616
workshops.each do |workshop|
@@ -189,7 +189,7 @@
189189

190190
scenario 'viewing a text file with all attendee emails' do
191191
workshop = Fabricate(:workshop)
192-
attendees = Fabricate.times(4, :attending_workshop_invitation, workshop: workshop)
192+
attendees = Fabricate.times(2, :attending_workshop_invitation, workshop: workshop)
193193
attendees_emails = attendees.map(&:member).map(&:email)
194194
visit admin_workshop_attendees_emails_path(workshop, format: :text)
195195

@@ -201,7 +201,7 @@
201201
context 'attendee names list' do
202202
scenario 'viewing a text file with all names' do
203203
workshop = Fabricate(:workshop)
204-
attendees = Fabricate.times(4, :attending_workshop_invitation, workshop: workshop)
204+
attendees = Fabricate.times(2, :attending_workshop_invitation, workshop: workshop)
205205
visit admin_workshop_attendees_checklist_path(workshop, format: :text)
206206
attendees.map(&:member).map(&:full_name).each do |name|
207207
expect(page).to have_content(name)

spec/features/chapter_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
it 'renders the 6 most recent sponsors for the chapter' do
6363
chapter = Fabricate(:chapter)
64-
workshops = 6.times.map do |n|
64+
workshops = 2.times.map do |n|
6565
Fabricate(:workshop, chapter: chapter, date_and_time: Time.zone.now - n.weeks)
6666
end
6767

spec/features/listing_coaches_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@
88
scenario 'I can see the top coaches by year' do
99
latest_workshop = Fabricate(:workshop, date_and_time: Time.zone.now - 1.year)
1010
old_workshop = Fabricate(:workshop, date_and_time: Time.zone.now - 3.years)
11-
invitations = 5.times { Fabricate(:attended_coach, workshop: latest_workshop) }
12-
older_invitations = 15.times { Fabricate(:attended_coach, workshop: old_workshop) }
11+
invitations = 2.times { Fabricate(:attended_coach, workshop: latest_workshop) }
12+
older_invitations = 4.times { Fabricate(:attended_coach, workshop: old_workshop) }
1313

1414
visit coaches_path(year: latest_workshop.date_and_time.year)
15-
expect(page).to have_css(".coach", count: 5)
15+
expect(page).to have_css(".coach", count: 2)
1616

1717
visit coaches_path(year: old_workshop.date_and_time.year)
18-
expect(page).to have_css(".coach", count: 15)
18+
expect(page).to have_css(".coach", count: 4)
1919
end
2020

2121
scenario 'I can navigate the top coaches by year' do
2222
current_workshop = Fabricate(:workshop, date_and_time: Time.zone.now)
2323
latest_workshop = Fabricate(:workshop, date_and_time: Time.zone.now - 1.year)
2424
old_workshop = Fabricate(:workshop, date_and_time: Time.zone.now - 3.years)
25-
current_invitations = 10.times { Fabricate(:attended_coach, workshop: current_workshop) }
26-
invitations = 7.times { Fabricate(:attended_coach, workshop: latest_workshop) }
27-
older_invitations = 12.times { Fabricate(:attended_coach, workshop: old_workshop) }
25+
current_invitations = 1.times { Fabricate(:attended_coach, workshop: current_workshop) }
26+
invitations = 3.times { Fabricate(:attended_coach, workshop: latest_workshop) }
27+
older_invitations = 2.times { Fabricate(:attended_coach, workshop: old_workshop) }
2828

2929
visit coaches_path
30-
expect(page).to have_css(".coach", count: 10)
30+
expect(page).to have_css(".coach", count: 1)
3131

3232
click_on latest_workshop.date_and_time.year.to_s
33-
expect(page).to have_css(".coach", count: 7)
33+
expect(page).to have_css(".coach", count: 3)
3434

3535
click_on old_workshop.date_and_time.year.to_s
36-
expect(page).to have_css(".coach", count: 12)
36+
expect(page).to have_css(".coach", count: 2)
3737
end
3838
end

spec/features/listing_events_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828

2929
context 'when there are more than the specified number of past events' do
3030
scenario 'I can only as many events allowed by the display limits' do
31-
Fabricate.times(10, :event, date_and_time: 2.weeks.ago)
32-
stub_const('EventsController::RECENT_EVENTS_DISPLAY_LIMIT', 10)
31+
Fabricate.times(2, :event, date_and_time: 2.weeks.ago)
32+
stub_const('EventsController::RECENT_EVENTS_DISPLAY_LIMIT', 2)
3333
Fabricate(:workshop, date_and_time: 3.weeks.ago)
3434

3535
visit events_path
3636
within('*[data-test=past-events]') do
37-
expect(page).to have_selector('*[data-test=event]', count: 10)
37+
expect(page).to have_selector('*[data-test=event]', count: 2)
3838
expect(page).not_to have_content 'Workshop'
3939
end
4040
end

spec/features/member_portal_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
end
7272

7373
it 'can view the invitations they RSVPed to' do
74-
invitations = 5.times.map { Fabricate(:attending_workshop_invitation, member: member) }
74+
invitations = 2.times.map { Fabricate(:attending_workshop_invitation, member: member) }
7575
visit invitations_path
7676

7777
expect(page).to have_content('Invitations')

spec/features/visiting_homepage_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
RSpec.feature 'when visiting the homepage', type: :feature do
22
let!(:next_workshop) { Fabricate(:workshop) }
3-
let!(:events) { Fabricate.times(8, :event) }
3+
let!(:events) { Fabricate.times(3, :event) }
44

55
before(:each) do
66
visit root_path
@@ -27,8 +27,8 @@
2727
end
2828

2929
scenario 'I can only view active chapters' do
30-
inactive_chapters = Fabricate.times(3, :chapter, active: false)
31-
active_chapters = Fabricate.times(4, :chapter)
30+
inactive_chapters = Fabricate.times(1, :chapter, active: false)
31+
active_chapters = Fabricate.times(2, :chapter)
3232

3333
visit root_path
3434

spec/lib/tasks/delete_member_rake_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
end
1616

1717
it 'anonymises member information' do
18-
invitations = Fabricate.times(4, :workshop_invitation, member: member)
18+
invitations = Fabricate.times(2, :workshop_invitation, member: member)
1919
tokens = invitations.map(&:token)
2020

21-
subscriptions = Fabricate.times(3, :subscription, member: member)
21+
subscriptions = Fabricate.times(1, :subscription, member: member)
2222

2323
allow($stdin).to receive(:getch)
2424

0 commit comments

Comments
 (0)