PERF: Make tests faster by prefabricating more things (#15370)

This commit is contained in:
Daniel Waterworth
2021-12-20 12:59:10 -06:00
committed by GitHub
parent 973c9bdcd3
commit 7e0c1fb039
7 changed files with 102 additions and 145 deletions

View File

@@ -4,7 +4,8 @@ require 'rails_helper'
require 'csv'
describe Jobs::ExportUserArchive do
let(:user) { Fabricate(:user, username: "john_doe") }
fab!(:user) { Fabricate(:user, username: "john_doe") }
fab!(:user2) { Fabricate(:user) }
let(:extra) { {} }
let(:job) {
j = Jobs::ExportUserArchive.new
@@ -14,10 +15,10 @@ describe Jobs::ExportUserArchive do
}
let(:component) { raise 'component not set' }
let(:admin) { Fabricate(:admin) }
let(:category) { Fabricate(:category_with_definition) }
let(:subcategory) { Fabricate(:category_with_definition, parent_category_id: category.id) }
let(:topic) { Fabricate(:topic, category: category) }
fab!(:admin) { Fabricate(:admin) }
fab!(:category) { Fabricate(:category_with_definition) }
fab!(:subcategory) { Fabricate(:category_with_definition, parent_category_id: category.id) }
fab!(:topic) { Fabricate(:topic, category: category) }
let(:post) { Fabricate(:post, user: user, topic: topic) }
def make_component_csv
@@ -111,7 +112,6 @@ describe Jobs::ExportUserArchive do
context 'user_archive posts' do
let(:component) { 'user_archive' }
let(:user2) { Fabricate(:user) }
let(:subsubcategory) { Fabricate(:category_with_definition, parent_category_id: subcategory.id) }
let(:subsubtopic) { Fabricate(:topic, category: subsubcategory) }
let(:subsubpost) { Fabricate(:post, user: user, topic: subsubtopic) }
@@ -453,7 +453,6 @@ describe Jobs::ExportUserArchive do
context 'visits' do
let(:component) { 'visits' }
let(:user2) { Fabricate(:user) }
it 'correctly exports the UserVisit table' do
freeze_time '2017-03-01 12:00'