mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
00a9369ca2
In a large forum with millions of users and millions of user_fields updating the list of dropdown user field options will result in a 502 now due to the large number of fields. This commit moves the indexing into a job.
21 lines
530 B
Ruby
21 lines
530 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe Jobs::IndexUserFieldsForSearch do
|
|
subject(:job) { described_class.new }
|
|
|
|
before do
|
|
SearchIndexer.enable
|
|
Jobs.run_immediately!
|
|
end
|
|
|
|
it "triggers a reindex when executed" do
|
|
user = Fabricate(:user)
|
|
user_field = Fabricate(:user_field)
|
|
Fabricate(:user_custom_field, user: user, name: "user_field_#{user_field.id}")
|
|
|
|
job.execute(user_field_id: user_field.id)
|
|
|
|
expect(user.reload.user_search_data.version).to eq(SearchIndexer::REINDEX_VERSION)
|
|
end
|
|
end
|