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
+3 -3
View File
@@ -4,8 +4,8 @@ require "rails_helper"
describe PostOwnerChanger do
describe "change_owner!" do
let!(:editor) { Fabricate(:admin) }
let(:user_a) { Fabricate(:user) }
fab!(:editor) { Fabricate(:admin) }
fab!(:user_a) { Fabricate(:user) }
let(:p1) { create_post(post_number: 1) }
let(:topic) { p1.topic }
let(:p2) { create_post(topic: topic, post_number: 2) }
@@ -190,7 +190,7 @@ describe PostOwnerChanger do
end
context 'private message topic' do
# let(:topic) { Fabricate(:private_message_topic) }
# fab!(:topic) { Fabricate(:private_message_topic) }
let(:pm) do
create_post(
archetype: 'private_message',