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 13:12:20 +10:00
committed by Sam
parent 329969ea20
commit e219588142
258 changed files with 1402 additions and 1364 deletions
+5 -5
View File
@@ -3,12 +3,12 @@
require 'rails_helper'
describe WatchedWord do
let(:tl2_user) { Fabricate(:user, trust_level: TrustLevel[2]) }
let(:admin) { Fabricate(:admin) }
let(:moderator) { Fabricate(:moderator) }
fab!(:tl2_user) { Fabricate(:user, trust_level: TrustLevel[2]) }
fab!(:admin) { Fabricate(:admin) }
fab!(:moderator) { Fabricate(:moderator) }
let(:topic) { Fabricate(:topic) }
let(:first_post) { Fabricate(:post, topic: topic) }
fab!(:topic) { Fabricate(:topic) }
fab!(:first_post) { Fabricate(:post, topic: topic) }
let(:require_approval_word) { Fabricate(:watched_word, action: WatchedWord.actions[:require_approval]) }
let(:flag_word) { Fabricate(:watched_word, action: WatchedWord.actions[:flag]) }