0
0
Fork 0

Move search and streaming spec manager classes to separate support files (#27727)

This commit is contained in:
Matt Jankowski 2023-11-07 10:25:49 -05:00 committed by GitHub
parent 02d27de5ce
commit ae7c20b00c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 121 additions and 119 deletions

View file

@ -0,0 +1,43 @@
# frozen_string_literal: true
class SearchDataManager
def prepare_test_data
4.times do |i|
username = "search_test_account_#{i}"
account = Fabricate.create(:account, username: username, indexable: i.even?, discoverable: i.even?, note: "Lover of #{i}.")
2.times do |j|
Fabricate.create(:status, account: account, text: "#{username}'s #{j} post", visibility: j.even? ? :public : :private)
end
end
3.times do |i|
Fabricate.create(:tag, name: "search_test_tag_#{i}")
end
end
def indexes
[
AccountsIndex,
PublicStatusesIndex,
StatusesIndex,
TagsIndex,
]
end
def populate_indexes
indexes.each do |index_class|
index_class.purge!
index_class.import!
end
end
def remove_indexes
indexes.each(&:delete!)
end
def cleanup_test_data
Status.destroy_all
Account.destroy_all
Tag.destroy_all
end
end