PERF: Shave off some test-suite time (#15183)

This commit is contained in:
Daniel Waterworth
2021-12-03 14:54:07 -06:00
committed by GitHub
parent 657c137384
commit 63112f89a3
7 changed files with 33 additions and 67 deletions
-2
View File
@@ -371,7 +371,6 @@ describe UserDestroyer do
describe "Destroying a user with security key" do
let!(:security_key) { Fabricate(:user_security_key_with_random_credential, user: user) }
fab!(:admin) { Fabricate(:admin) }
it "removes the security key" do
UserDestroyer.new(admin).destroy(user)
@@ -381,7 +380,6 @@ describe UserDestroyer do
describe "Destroying a user with a bookmark" do
let!(:bookmark) { Fabricate(:bookmark, user: user) }
fab!(:admin) { Fabricate(:admin) }
it "removes the bookmark" do
UserDestroyer.new(admin).destroy(user)
+13 -21
View File
@@ -7,6 +7,13 @@ describe UserMerger do
fab!(:source_user) { Fabricate(:user, username: 'alice1', email: 'alice@work.com') }
fab!(:walter) { Fabricate(:walter_white) }
fab!(:p1) { Fabricate(:post) }
fab!(:p2) { Fabricate(:post) }
fab!(:p3) { Fabricate(:post) }
fab!(:p4) { Fabricate(:post) }
fab!(:p5) { Fabricate(:post) }
fab!(:p6) { Fabricate(:post) }
def merge_users!(source = nil, target = nil)
source ||= source_user
target ||= target_user
@@ -154,13 +161,6 @@ describe UserMerger do
end
it "merges likes" do
p1 = Fabricate(:post)
p2 = Fabricate(:post)
p3 = Fabricate(:post)
p4 = Fabricate(:post)
p5 = Fabricate(:post)
p6 = Fabricate(:post)
now = Time.zone.now
freeze_time(now - 1.day)
@@ -334,9 +334,6 @@ describe UserMerger do
context "post actions" do
it "merges post actions" do
p1 = Fabricate(:post)
p2 = Fabricate(:post)
p3 = Fabricate(:post)
type_ids = PostActionType.public_type_ids + [PostActionType.flag_types.values.first]
type_ids.each do |type|
@@ -357,11 +354,6 @@ describe UserMerger do
end
it "updates post actions" do
p1 = Fabricate(:post)
p2 = Fabricate(:post)
p3 = Fabricate(:post)
p4 = Fabricate(:post)
action1 = PostActionCreator.create(source_user, p1, :off_topic).post_action
action1.update_attribute(:deleted_by_id, source_user.id)
@@ -384,7 +376,7 @@ describe UserMerger do
end
it "updates post revisions" do
post = Fabricate(:post)
post = p1
post_revision = Fabricate(:post_revision, post: post, user: source_user)
merge_users!
@@ -410,9 +402,9 @@ describe UserMerger do
end
it "merges post timings" do
post1 = Fabricate(:post)
post2 = Fabricate(:post)
post3 = Fabricate(:post)
post1 = p1
post2 = p2
post3 = p3
create_post_timing(post1, source_user, 12345)
create_post_timing(post2, source_user, 9876)
@@ -678,8 +670,8 @@ describe UserMerger do
# action_type and user_id are not nullable
# target_topic_id and acting_user_id are nullable, but always have a value
fab!(:post1) { Fabricate(:post) }
fab!(:post2) { Fabricate(:post) }
fab!(:post1) { p1 }
fab!(:post2) { p2 }
def log_like_action(acting_user, user, post)
UserAction.log_action!(action_type: UserAction::LIKE,