DEV: Prefabrication (test optimization) (#7414)

* Introduced fab!, a helper that creates database state for a group

It's almost identical to let_it_be, except:

 1. It creates a new object for each test by default,
 2. You can disable it using PREFABRICATION=0
This commit is contained in:
Daniel Waterworth
2019-05-07 03:12:20 +00:00
committed by Sam
parent 329969ea20
commit e219588142
258 changed files with 1402 additions and 1364 deletions

View File

@ -89,9 +89,9 @@ describe UserUpdater do
end
describe '#update' do
let(:category) { Fabricate(:category) }
let(:tag) { Fabricate(:tag) }
let(:tag2) { Fabricate(:tag) }
fab!(:category) { Fabricate(:category) }
fab!(:tag) { Fabricate(:tag) }
fab!(:tag2) { Fabricate(:tag) }
it 'saves user' do
user = Fabricate(:user, name: 'Billy Bob')
@ -274,8 +274,8 @@ describe UserUpdater do
end
context 'title is from a badge' do
let(:user) { Fabricate(:user, title: 'Emperor') }
let(:badge) { Fabricate(:badge, name: 'Minion') }
fab!(:user) { Fabricate(:user, title: 'Emperor') }
fab!(:badge) { Fabricate(:badge, name: 'Minion') }
context 'badge can be used as a title' do
before do