From a4cc606291c9d898f43c86685efa55a7cab35679 Mon Sep 17 00:00:00 2001 From: Molly Struve Date: Wed, 29 Apr 2020 12:12:29 -0500 Subject: [PATCH] [deploy] Remove Elasticsearch from Index Worker Names (#7594) --- app/models/concerns/searchable.rb | 4 ++-- app/services/users/delete_activity.rb | 2 +- app/services/users/delete_articles.rb | 2 +- ..._elasticsearch_worker.rb => bulk_index_worker.rb} | 2 +- ...ex_to_elasticsearch_worker.rb => index_worker.rb} | 2 +- ...h_index_worker.rb => remove_from_index_worker.rb} | 2 +- .../20200305201627_index_users_to_elasticsearch.rb | 2 +- ...0305201642_index_feed_content_to_elasticsearch.rb | 4 ++-- .../20200313123108_index_users_to_elasticsearch.rb | 2 +- ...6145114_re_index_feed_content_to_elasticsearch.rb | 2 +- ...20200406213152_re_index_users_to_elasticsearch.rb | 2 +- .../20200410152018_resync_elasticsearch_documents.rb | 2 +- .../20200415200651_index_reading_list_reactions.rb | 2 +- spec/models/article_spec.rb | 8 ++++---- spec/models/chat_channel_membership_spec.rb | 4 ++-- spec/models/classified_listing_spec.rb | 5 ++--- spec/models/comment_spec.rb | 4 ++-- spec/models/concerns/searchable_spec.rb | 4 ++-- spec/models/podcast_episode_spec.rb | 4 ++-- spec/models/reaction_spec.rb | 12 ++++++------ spec/models/tag_spec.rb | 4 ++-- spec/models/user_spec.rb | 6 ++---- spec/services/moderator/banish_user_spec.rb | 2 +- spec/services/users/delete_articles_spec.rb | 2 +- ...arch_worker_spec.rb => bulk_index_worker_spec.rb} | 2 +- ...ticsearch_worker_spec.rb => index_worker_spec.rb} | 2 +- ...rker_spec.rb => remove_from_index_worker_spec.rb} | 2 +- 27 files changed, 44 insertions(+), 47 deletions(-) rename app/workers/search/{bulk_index_to_elasticsearch_worker.rb => bulk_index_worker.rb} (90%) rename app/workers/search/{index_to_elasticsearch_worker.rb => index_worker.rb} (93%) rename app/workers/search/{remove_from_elasticsearch_index_worker.rb => remove_from_index_worker.rb} (91%) rename spec/workers/search/{bulk_index_to_elasticsearch_worker_spec.rb => bulk_index_worker_spec.rb} (88%) rename spec/workers/search/{index_to_elasticsearch_worker_spec.rb => index_worker_spec.rb} (88%) rename spec/workers/search/{remove_from_elasticsearch_index_worker_spec.rb => remove_from_index_worker_spec.rb} (91%) diff --git a/app/models/concerns/searchable.rb b/app/models/concerns/searchable.rb index 3866ff0f7..555ff0fe0 100644 --- a/app/models/concerns/searchable.rb +++ b/app/models/concerns/searchable.rb @@ -4,7 +4,7 @@ module Searchable end def index_to_elasticsearch - Search::IndexToElasticsearchWorker.perform_async(self.class.name, id) + Search::IndexWorker.perform_async(self.class.name, id) end def index_to_elasticsearch_inline @@ -12,7 +12,7 @@ module Searchable end def remove_from_elasticsearch - Search::RemoveFromElasticsearchIndexWorker.perform_async(self.class::SEARCH_CLASS.to_s, search_id) + Search::RemoveFromIndexWorker.perform_async(self.class::SEARCH_CLASS.to_s, search_id) end def serialized_search_hash diff --git a/app/services/users/delete_activity.rb b/app/services/users/delete_activity.rb index 10a6f450a..d153bd82c 100644 --- a/app/services/users/delete_activity.rb +++ b/app/services/users/delete_activity.rb @@ -59,7 +59,7 @@ module Users readinglist_ids = user.reactions.readinglist.pluck(:id) user.reactions.delete_all readinglist_ids.each do |id| - Search::RemoveFromElasticsearchIndexWorker.perform_async("Search::Reaction", id) + Search::RemoveFromIndexWorker.perform_async("Search::Reaction", id) end end end diff --git a/app/services/users/delete_articles.rb b/app/services/users/delete_articles.rb index 3e4b21869..5ff6c592f 100644 --- a/app/services/users/delete_articles.rb +++ b/app/services/users/delete_articles.rb @@ -29,7 +29,7 @@ module Users readinglist_ids = article.reactions.readinglist.pluck(:id) article.reactions.delete_all readinglist_ids.each do |id| - Search::RemoveFromElasticsearchIndexWorker.perform_async("Search::Reaction", id) + Search::RemoveFromIndexWorker.perform_async("Search::Reaction", id) end end end diff --git a/app/workers/search/bulk_index_to_elasticsearch_worker.rb b/app/workers/search/bulk_index_worker.rb similarity index 90% rename from app/workers/search/bulk_index_to_elasticsearch_worker.rb rename to app/workers/search/bulk_index_worker.rb index c7f21d4af..bf6daf375 100644 --- a/app/workers/search/bulk_index_to_elasticsearch_worker.rb +++ b/app/workers/search/bulk_index_worker.rb @@ -1,5 +1,5 @@ module Search - class BulkIndexToElasticsearchWorker + class BulkIndexWorker include Sidekiq::Worker sidekiq_options queue: :high_priority, lock: :until_executing diff --git a/app/workers/search/index_to_elasticsearch_worker.rb b/app/workers/search/index_worker.rb similarity index 93% rename from app/workers/search/index_to_elasticsearch_worker.rb rename to app/workers/search/index_worker.rb index b1111025f..73ec0d1e4 100644 --- a/app/workers/search/index_to_elasticsearch_worker.rb +++ b/app/workers/search/index_worker.rb @@ -1,5 +1,5 @@ module Search - class IndexToElasticsearchWorker + class IndexWorker include Sidekiq::Worker sidekiq_options queue: :high_priority, lock: :until_executing diff --git a/app/workers/search/remove_from_elasticsearch_index_worker.rb b/app/workers/search/remove_from_index_worker.rb similarity index 91% rename from app/workers/search/remove_from_elasticsearch_index_worker.rb rename to app/workers/search/remove_from_index_worker.rb index 5416d5851..e6ef3ee82 100644 --- a/app/workers/search/remove_from_elasticsearch_index_worker.rb +++ b/app/workers/search/remove_from_index_worker.rb @@ -1,5 +1,5 @@ module Search - class RemoveFromElasticsearchIndexWorker + class RemoveFromIndexWorker include Sidekiq::Worker sidekiq_options queue: :medium_priority, lock: :until_executing diff --git a/lib/data_update_scripts/20200305201627_index_users_to_elasticsearch.rb b/lib/data_update_scripts/20200305201627_index_users_to_elasticsearch.rb index e46d9f217..f49b987f8 100644 --- a/lib/data_update_scripts/20200305201627_index_users_to_elasticsearch.rb +++ b/lib/data_update_scripts/20200305201627_index_users_to_elasticsearch.rb @@ -2,7 +2,7 @@ module DataUpdateScripts class IndexUsersToElasticsearch def run # User.select(:id).find_each do |user| - # Search::IndexToElasticsearchWorker.set(queue: :low_priority).perform_async( + # Search::IndexWorker.set(queue: :low_priority).perform_async( # "User", user.id # ) # end diff --git a/lib/data_update_scripts/20200305201642_index_feed_content_to_elasticsearch.rb b/lib/data_update_scripts/20200305201642_index_feed_content_to_elasticsearch.rb index 02c70f7ab..27cf62e74 100644 --- a/lib/data_update_scripts/20200305201642_index_feed_content_to_elasticsearch.rb +++ b/lib/data_update_scripts/20200305201642_index_feed_content_to_elasticsearch.rb @@ -2,13 +2,13 @@ module DataUpdateScripts class IndexFeedContentToElasticsearch def run # Article.select(:id).find_each do |article| - # Search::IndexToElasticsearchWorker.set(queue: :low_priority).perform_async( + # Search::IndexWorker.set(queue: :low_priority).perform_async( # "Article", article.id # ) # end # PodcastEpisode.select(:id).find_each do |pde| - # Search::IndexToElasticsearchWorker.set(queue: :low_priority).perform_async( + # Search::IndexWorker.set(queue: :low_priority).perform_async( # "PodcastEpisode", pde.id # ) # end diff --git a/lib/data_update_scripts/20200313123108_index_users_to_elasticsearch.rb b/lib/data_update_scripts/20200313123108_index_users_to_elasticsearch.rb index e46d9f217..f49b987f8 100644 --- a/lib/data_update_scripts/20200313123108_index_users_to_elasticsearch.rb +++ b/lib/data_update_scripts/20200313123108_index_users_to_elasticsearch.rb @@ -2,7 +2,7 @@ module DataUpdateScripts class IndexUsersToElasticsearch def run # User.select(:id).find_each do |user| - # Search::IndexToElasticsearchWorker.set(queue: :low_priority).perform_async( + # Search::IndexWorker.set(queue: :low_priority).perform_async( # "User", user.id # ) # end diff --git a/lib/data_update_scripts/20200326145114_re_index_feed_content_to_elasticsearch.rb b/lib/data_update_scripts/20200326145114_re_index_feed_content_to_elasticsearch.rb index 8ec3005f3..c49775ffb 100644 --- a/lib/data_update_scripts/20200326145114_re_index_feed_content_to_elasticsearch.rb +++ b/lib/data_update_scripts/20200326145114_re_index_feed_content_to_elasticsearch.rb @@ -19,7 +19,7 @@ module DataUpdateScripts def index_docs(ids, doc_type) ids.each do |id| - Search::IndexToElasticsearchWorker.set(queue: :low_priority).perform_async( + Search::IndexWorker.set(queue: :low_priority).perform_async( doc_type, id ) end diff --git a/lib/data_update_scripts/20200406213152_re_index_users_to_elasticsearch.rb b/lib/data_update_scripts/20200406213152_re_index_users_to_elasticsearch.rb index 7ab432a89..fa3f03ad7 100644 --- a/lib/data_update_scripts/20200406213152_re_index_users_to_elasticsearch.rb +++ b/lib/data_update_scripts/20200406213152_re_index_users_to_elasticsearch.rb @@ -2,7 +2,7 @@ module DataUpdateScripts class ReIndexUsersToElasticsearch def run User.select(:id).find_each do |user| - Search::IndexToElasticsearchWorker.set(queue: :low_priority).perform_async( + Search::IndexWorker.set(queue: :low_priority).perform_async( "User", user.id ) end diff --git a/lib/data_update_scripts/20200410152018_resync_elasticsearch_documents.rb b/lib/data_update_scripts/20200410152018_resync_elasticsearch_documents.rb index 9bd92de58..e4069874b 100644 --- a/lib/data_update_scripts/20200410152018_resync_elasticsearch_documents.rb +++ b/lib/data_update_scripts/20200410152018_resync_elasticsearch_documents.rb @@ -15,7 +15,7 @@ module DataUpdateScripts def index_docs(ids, doc_type) ids.each do |id| - Search::IndexToElasticsearchWorker.set(queue: :low_priority).perform_async( + Search::IndexWorker.set(queue: :low_priority).perform_async( doc_type, id ) end diff --git a/lib/data_update_scripts/20200415200651_index_reading_list_reactions.rb b/lib/data_update_scripts/20200415200651_index_reading_list_reactions.rb index 971e2aba7..b1364bbff 100644 --- a/lib/data_update_scripts/20200415200651_index_reading_list_reactions.rb +++ b/lib/data_update_scripts/20200415200651_index_reading_list_reactions.rb @@ -2,7 +2,7 @@ module DataUpdateScripts class IndexReadingListReactions def run Reaction.readinglist.select(:id).in_batches do |batch| - Search::BulkIndexToElasticsearchWorker.set(queue: :default).perform_async( + Search::BulkIndexWorker.set(queue: :default).perform_async( "Reaction", batch.pluck(:id) ) end diff --git a/spec/models/article_spec.rb b/spec/models/article_spec.rb index abf8e575e..4dd4365cb 100644 --- a/spec/models/article_spec.rb +++ b/spec/models/article_spec.rb @@ -32,7 +32,7 @@ RSpec.describe Article, type: :model do describe "#after_commit" do it "on update enqueues job to index article to elasticsearch" do article.save - sidekiq_assert_enqueued_with(job: Search::IndexToElasticsearchWorker, args: [described_class.to_s, article.id]) do + sidekiq_assert_enqueued_with(job: Search::IndexWorker, args: [described_class.to_s, article.id]) do article.save end end @@ -40,7 +40,7 @@ RSpec.describe Article, type: :model do it "on destroy enqueues job to delete article from elasticsearch" do article = create(:article) - sidekiq_assert_enqueued_with(job: Search::RemoveFromElasticsearchIndexWorker, args: [described_class::SEARCH_CLASS.to_s, article.search_id]) do + sidekiq_assert_enqueued_with(job: Search::RemoveFromIndexWorker, args: [described_class::SEARCH_CLASS.to_s, article.search_id]) do article.destroy end end @@ -83,7 +83,7 @@ RSpec.describe Article, type: :model do allow(article).to receive(:index_to_elasticsearch) allow(article.user).to receive(:index_to_elasticsearch) - sidekiq_assert_enqueued_with(job: Search::IndexToElasticsearchWorker, args: ["Reaction", reaction.id]) do + sidekiq_assert_enqueued_with(job: Search::IndexWorker, args: ["Reaction", reaction.id]) do article.update(body_markdown: "---\ntitle: NEW TITLE#{rand(1000)}\n") end end @@ -826,7 +826,7 @@ RSpec.describe Article, type: :model do describe "#touch_by_reaction" do it "reindexes elasticsearch doc" do - sidekiq_assert_enqueued_with(job: Search::IndexToElasticsearchWorker, args: [described_class.to_s, article.id]) do + sidekiq_assert_enqueued_with(job: Search::IndexWorker, args: [described_class.to_s, article.id]) do article.touch_by_reaction end end diff --git a/spec/models/chat_channel_membership_spec.rb b/spec/models/chat_channel_membership_spec.rb index 8db296ea4..9b29f3fa0 100644 --- a/spec/models/chat_channel_membership_spec.rb +++ b/spec/models/chat_channel_membership_spec.rb @@ -15,14 +15,14 @@ RSpec.describe ChatChannelMembership, type: :model do describe "#after_commit" do it "on update enqueues job to index chat_channel_membership to elasticsearch" do chat_channel_membership.save - sidekiq_assert_enqueued_with(job: Search::IndexToElasticsearchWorker, args: [described_class.to_s, chat_channel_membership.id]) do + sidekiq_assert_enqueued_with(job: Search::IndexWorker, args: [described_class.to_s, chat_channel_membership.id]) do chat_channel_membership.save end end it "on destroy enqueues job to delete chat_channel_membership from elasticsearch" do chat_channel_membership.save - sidekiq_assert_enqueued_with(job: Search::RemoveFromElasticsearchIndexWorker, args: [described_class::SEARCH_CLASS.to_s, chat_channel_membership.id]) do + sidekiq_assert_enqueued_with(job: Search::RemoveFromIndexWorker, args: [described_class::SEARCH_CLASS.to_s, chat_channel_membership.id]) do chat_channel_membership.destroy end end diff --git a/spec/models/classified_listing_spec.rb b/spec/models/classified_listing_spec.rb index 74556d638..abdd532ed 100644 --- a/spec/models/classified_listing_spec.rb +++ b/spec/models/classified_listing_spec.rb @@ -76,17 +76,16 @@ RSpec.describe ClassifiedListing, type: :model do it "on update enqueues worker to index tag to elasticsearch" do classified_listing.save - sidekiq_assert_enqueued_with(job: Search::IndexToElasticsearchWorker, args: [described_class.to_s, classified_listing.id]) do + sidekiq_assert_enqueued_with(job: Search::IndexWorker, args: [described_class.to_s, classified_listing.id]) do classified_listing.save end end it "on destroy enqueues job to delete classified_listing from elasticsearch" do classified_listing.save - sidekiq_assert_enqueued_with(job: Search::RemoveFromElasticsearchIndexWorker, args: [described_class::SEARCH_CLASS.to_s, classified_listing.id]) do + sidekiq_assert_enqueued_with(job: Search::RemoveFromIndexWorker, args: [described_class::SEARCH_CLASS.to_s, classified_listing.id]) do classified_listing.destroy end end end end - diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 05ec15b91..fe711180d 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -39,7 +39,7 @@ RSpec.describe Comment, type: :model do describe "#after_commit" do it "on update enqueues job to index comment to elasticsearch" do - sidekiq_assert_enqueued_with(job: Search::IndexToElasticsearchWorker, args: [described_class.to_s, comment.id]) do + sidekiq_assert_enqueued_with(job: Search::IndexWorker, args: [described_class.to_s, comment.id]) do comment.save end end @@ -47,7 +47,7 @@ RSpec.describe Comment, type: :model do it "on destroy enqueues job to delete comment from elasticsearch" do comment = create(:comment) - sidekiq_assert_enqueued_with(job: Search::RemoveFromElasticsearchIndexWorker, args: [described_class::SEARCH_CLASS.to_s, comment.search_id]) do + sidekiq_assert_enqueued_with(job: Search::RemoveFromIndexWorker, args: [described_class::SEARCH_CLASS.to_s, comment.search_id]) do comment.destroy end end diff --git a/spec/models/concerns/searchable_spec.rb b/spec/models/concerns/searchable_spec.rb index d99772fc1..2347824d5 100644 --- a/spec/models/concerns/searchable_spec.rb +++ b/spec/models/concerns/searchable_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Searchable do describe "#remove_from_elasticsearch" do it "enqueues job to delete model document from elasticsearch" do - sidekiq_assert_enqueued_with(job: Search::RemoveFromElasticsearchIndexWorker, args: [SearchableModel::SEARCH_CLASS.to_s, searchable_model.search_id]) do + sidekiq_assert_enqueued_with(job: Search::RemoveFromIndexWorker, args: [SearchableModel::SEARCH_CLASS.to_s, searchable_model.search_id]) do searchable_model.remove_from_elasticsearch end end @@ -39,7 +39,7 @@ RSpec.describe Searchable do describe "#index_to_elasticsearch" do it "enqueues job to index document to elasticsearch" do - sidekiq_assert_enqueued_with(job: Search::IndexToElasticsearchWorker, args: ["SearchableModel", searchable_model.id]) do + sidekiq_assert_enqueued_with(job: Search::IndexWorker, args: ["SearchableModel", searchable_model.id]) do searchable_model.index_to_elasticsearch end end diff --git a/spec/models/podcast_episode_spec.rb b/spec/models/podcast_episode_spec.rb index 70bf843cf..00afb8c0c 100644 --- a/spec/models/podcast_episode_spec.rb +++ b/spec/models/podcast_episode_spec.rb @@ -32,14 +32,14 @@ RSpec.describe PodcastEpisode, type: :model do describe "#after_commit" do it "on update enqueues job to index podcast_episode to elasticsearch" do podcast_episode.save - sidekiq_assert_enqueued_with(job: Search::IndexToElasticsearchWorker, args: [described_class.to_s, podcast_episode.id]) do + sidekiq_assert_enqueued_with(job: Search::IndexWorker, args: [described_class.to_s, podcast_episode.id]) do podcast_episode.save end end it "on destroy enqueues job to delete podcast_episode from elasticsearch" do podcast_episode.save - sidekiq_assert_enqueued_with(job: Search::RemoveFromElasticsearchIndexWorker, args: [described_class::SEARCH_CLASS.to_s, podcast_episode.search_id]) do + sidekiq_assert_enqueued_with(job: Search::RemoveFromIndexWorker, args: [described_class::SEARCH_CLASS.to_s, podcast_episode.search_id]) do podcast_episode.destroy end end diff --git a/spec/models/reaction_spec.rb b/spec/models/reaction_spec.rb index 2cf534775..b2c936ee9 100644 --- a/spec/models/reaction_spec.rb +++ b/spec/models/reaction_spec.rb @@ -72,14 +72,14 @@ RSpec.describe Reaction, type: :model do context "when category is readingList and reactable is published" do it "on update enqueues job to index reaction to elasticsearch" do reaction.save - sidekiq_assert_enqueued_with(job: Search::IndexToElasticsearchWorker, args: [described_class.to_s, reaction.id]) do + sidekiq_assert_enqueued_with(job: Search::IndexWorker, args: [described_class.to_s, reaction.id]) do reaction.update(category: "readinglist") end end it "on create enqueues job to index reaction to elasticsearch" do reaction.category = "readinglist" - sidekiq_assert_enqueued_with(job: Search::IndexToElasticsearchWorker) do + sidekiq_assert_enqueued_with(job: Search::IndexWorker) do reaction.save end end @@ -87,7 +87,7 @@ RSpec.describe Reaction, type: :model do it "on destroy enqueues job to delete reaction from elasticsearch" do reaction.category = "readinglist" reaction.save - sidekiq_assert_enqueued_with(job: Search::RemoveFromElasticsearchIndexWorker, args: [described_class::SEARCH_CLASS.to_s, reaction.id]) do + sidekiq_assert_enqueued_with(job: Search::RemoveFromIndexWorker, args: [described_class::SEARCH_CLASS.to_s, reaction.id]) do reaction.destroy end end @@ -103,20 +103,20 @@ RSpec.describe Reaction, type: :model do it "on update does not enqueue job to index reaction to elasticsearch" do reaction.save - sidekiq_assert_no_enqueued_jobs(only: Search::IndexToElasticsearchWorker) do + sidekiq_assert_no_enqueued_jobs(only: Search::IndexWorker) do reaction.update(category: "unicorn") end end it "on create does not enqueue job to index reaction to elasticsearch" do - sidekiq_assert_no_enqueued_jobs(only: Search::IndexToElasticsearchWorker) do + sidekiq_assert_no_enqueued_jobs(only: Search::IndexWorker) do reaction.save end end it "on destroy does not enqueue job to delete reaction from elasticsearch" do reaction.save - sidekiq_assert_no_enqueued_jobs(only: Search::RemoveFromElasticsearchIndexWorker) do + sidekiq_assert_no_enqueued_jobs(only: Search::RemoveFromIndexWorker) do reaction.destroy end end diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 45e353285..584a80883 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -92,14 +92,14 @@ RSpec.describe Tag, type: :model do describe "#after_commit" do it "on update enqueues job to index tag to elasticsearch" do tag.save - sidekiq_assert_enqueued_with(job: Search::IndexToElasticsearchWorker, args: [described_class.to_s, tag.id]) do + sidekiq_assert_enqueued_with(job: Search::IndexWorker, args: [described_class.to_s, tag.id]) do tag.save end end it "on destroy enqueues job to delete tag from elasticsearch" do tag.save - sidekiq_assert_enqueued_with(job: Search::RemoveFromElasticsearchIndexWorker, args: [described_class::SEARCH_CLASS.to_s, tag.id]) do + sidekiq_assert_enqueued_with(job: Search::RemoveFromIndexWorker, args: [described_class::SEARCH_CLASS.to_s, tag.id]) do tag.destroy end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 966d5db4f..fe0459c3e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -139,10 +139,8 @@ RSpec.describe User, type: :model do expect(fourth_field).not_to be_valid end - it { is_expected.to have_many(:organization_memberships).dependent(:destroy) } it { is_expected.to have_one(:counters).class_name("UserCounter").dependent(:destroy) } it { is_expected.to have_one(:pro_membership).dependent(:destroy) } - it { is_expected.to validate_uniqueness_of(:username).case_insensitive } it { is_expected.not_to allow_value("#xyz").for(:bg_color_hex) } it { is_expected.not_to allow_value("#xyz").for(:text_color_hex) } it { is_expected.not_to allow_value("AcMe_1%").for(:username) } @@ -206,7 +204,7 @@ RSpec.describe User, type: :model do describe "#after_commit" do it "on update enqueues job to index user to elasticsearch" do user.save - sidekiq_assert_enqueued_with(job: Search::IndexToElasticsearchWorker, args: [described_class.to_s, user.id]) do + sidekiq_assert_enqueued_with(job: Search::IndexWorker, args: [described_class.to_s, user.id]) do user.save end end @@ -219,7 +217,7 @@ RSpec.describe User, type: :model do it "on destroy enqueues job to delete user from elasticsearch" do user.save - sidekiq_assert_enqueued_with(job: Search::RemoveFromElasticsearchIndexWorker, args: [described_class::SEARCH_CLASS.to_s, user.id]) do + sidekiq_assert_enqueued_with(job: Search::RemoveFromIndexWorker, args: [described_class::SEARCH_CLASS.to_s, user.id]) do user.destroy end end diff --git a/spec/services/moderator/banish_user_spec.rb b/spec/services/moderator/banish_user_spec.rb index e2235323e..2f615417b 100644 --- a/spec/services/moderator/banish_user_spec.rb +++ b/spec/services/moderator/banish_user_spec.rb @@ -27,7 +27,7 @@ RSpec.describe Moderator::BanishUser, type: :service do create(:comment, user: user, commentable: article) sidekiq_perform_enqueued_jobs - sidekiq_perform_enqueued_jobs(except: Search::IndexToElasticsearchWorker) do + sidekiq_perform_enqueued_jobs(except: Search::IndexWorker) do described_class.call(user: user, admin: admin) end expect(user.comments.count).to eq 0 diff --git a/spec/services/users/delete_articles_spec.rb b/spec/services/users/delete_articles_spec.rb index f530373cd..0419615f9 100644 --- a/spec/services/users/delete_articles_spec.rb +++ b/spec/services/users/delete_articles_spec.rb @@ -57,7 +57,7 @@ RSpec.describe Users::DeleteArticles, type: :service do sidekiq_perform_enqueued_jobs comments = article.comments comments.each { |comment| expect(comment.elasticsearch_doc).not_to be_nil } - sidekiq_perform_enqueued_jobs(only: Search::RemoveFromElasticsearchIndexWorker) do + sidekiq_perform_enqueued_jobs(only: Search::RemoveFromIndexWorker) do described_class.call(user) end diff --git a/spec/workers/search/bulk_index_to_elasticsearch_worker_spec.rb b/spec/workers/search/bulk_index_worker_spec.rb similarity index 88% rename from spec/workers/search/bulk_index_to_elasticsearch_worker_spec.rb rename to spec/workers/search/bulk_index_worker_spec.rb index 44fddd7e3..3713759f8 100644 --- a/spec/workers/search/bulk_index_to_elasticsearch_worker_spec.rb +++ b/spec/workers/search/bulk_index_worker_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Search::BulkIndexToElasticsearchWorker, type: :worker, elasticsearch: true do +RSpec.describe Search::BulkIndexWorker, type: :worker, elasticsearch: true do let(:worker) { subject } let(:article) { create(:article) } diff --git a/spec/workers/search/index_to_elasticsearch_worker_spec.rb b/spec/workers/search/index_worker_spec.rb similarity index 88% rename from spec/workers/search/index_to_elasticsearch_worker_spec.rb rename to spec/workers/search/index_worker_spec.rb index 030bff17a..5fb8aa043 100644 --- a/spec/workers/search/index_to_elasticsearch_worker_spec.rb +++ b/spec/workers/search/index_worker_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Search::IndexToElasticsearchWorker, type: :worker, elasticsearch: true do +RSpec.describe Search::IndexWorker, type: :worker, elasticsearch: true do let(:worker) { subject } include_examples "#enqueues_on_correct_queue", "high_priority", ["Tag", 1] diff --git a/spec/workers/search/remove_from_elasticsearch_index_worker_spec.rb b/spec/workers/search/remove_from_index_worker_spec.rb similarity index 91% rename from spec/workers/search/remove_from_elasticsearch_index_worker_spec.rb rename to spec/workers/search/remove_from_index_worker_spec.rb index 696819652..5d5562de5 100644 --- a/spec/workers/search/remove_from_elasticsearch_index_worker_spec.rb +++ b/spec/workers/search/remove_from_index_worker_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Search::RemoveFromElasticsearchIndexWorker, type: :worker do +RSpec.describe Search::RemoveFromIndexWorker, type: :worker do let(:worker) { subject } let(:search_class) { Search::Tag }