Skip to content

Commit f693339

Browse files
committed
Chore: reduce test suite run time by reducing test data fabrication
Reduce test run time by reducing the amount of test data is fabricated in test files
1 parent f06a3d1 commit f693339

21 files changed

+65
-65
lines changed

spec/features/admin/chapter/feedback_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
workshop = Fabricate(:workshop, chapter: chapter)
66
other_workshop = Fabricate(:workshop)
77

8-
feedbacks = Fabricate.times(3, :feedback, workshop: workshop)
9-
other_feedbacks = Fabricate.times(3, :feedback, workshop: other_workshop)
8+
feedbacks = Fabricate.times(1, :feedback, workshop: workshop)
9+
other_feedbacks = Fabricate.times(1, :feedback, workshop: other_workshop)
1010

1111
login_as_organiser(member, chapter)
1212

spec/features/admin/feedback_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
end
88

99
it 'can access the feedback page' do
10-
feedbacks = Fabricate.times(10, :feedback)
10+
feedbacks = Fabricate.times(2, :feedback)
1111

1212
visit admin_feedback_index_path
1313
feedbacks.each { |feedback| expect(page).to have_content(feedback.request) }

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')

0 commit comments

Comments
 (0)