Skip to content

A platform for community discussion. Free, open, simple.

DEV: avoid calling sidekiq in migration (#33957)

Sam0f78e29b1a17
diff --git a/plugins/discourse-rss-polling/app/jobs/jobs/discourse_rss_polling/fix_topic_embed_authors.rb b/plugins/discourse-rss-polling/app/jobs/jobs/discourse_rss_polling/fix_topic_embed_authors.rb
deleted file mode 100644
index 16fc7f04065..00000000000
--- a/plugins/discourse-rss-polling/app/jobs/jobs/discourse_rss_polling/fix_topic_embed_authors.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-module Jobs
- module DiscourseRssPolling
- class FixTopicEmbedAuthors < ::Jobs::Base
- sidekiq_options queue: "low"
-
- def mismatched_topic_embeds
- TopicEmbed.joins(post: :topic).where("posts.user_id != topics.user_id")
- end
-
- def execute(args)
- mismatched_topic_embeds.find_each do |topic_embed|
- post = topic_embed.post
-
- PostOwnerChanger.new(
- post_ids: [post.id],
- topic_id: post.topic_id,
- new_owner: post.user,
- acting_user: Discourse.system_user,
- skip_revision: true,
- ).change_owner!
- end
- end
- end
- end
-end
diff --git a/plugins/discourse-rss-polling/db/migrate/20180828095129_push_fix_topic_embed_authors_job.rb b/plugins/discourse-rss-polling/db/migrate/20180828095129_push_fix_topic_embed_authors_job.rb
deleted file mode 100644
index a1ca719a567..00000000000
--- a/plugins/discourse-rss-polling/db/migrate/20180828095129_push_fix_topic_embed_authors_job.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class PushFixTopicEmbedAuthorsJob < ActiveRecord::Migration[5.2]
- def change
- Jobs.enqueue("DiscourseRssPolling::FixTopicEmbedAuthors")
- end
-end
diff --git a/plugins/discourse-rss-polling/spec/jobs/fix_topic_embed_authors_spec.rb b/plugins/discourse-rss-polling/spec/jobs/fix_topic_embed_authors_spec.rb
deleted file mode 100644
index 245e3290657..00000000000
--- a/plugins/discourse-rss-polling/spec/jobs/fix_topic_embed_authors_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Jobs::DiscourseRssPolling::FixTopicEmbedAuthors do
- let(:job) { Jobs::DiscourseRssPolling::FixTopicEmbedAuthors.new }
-
- describe "#execute" do
- before { Jobs.run_later! }
-
- it "makes sure the topic and first post have the same author" do
- Sidekiq::Testing.fake! do
- topic_embed = create_mismatched_topic_embed
- post = topic_embed.post
- expected_user = post.user
-
- expect(post.user).to_not eq(post.topic.user)
-
- job.execute({})
-
- post.reload
- expect(post.user).to eq(expected_user)
- expect(post.user).to eq(post.topic.user)
- end
- end
-
- def create_mismatched_topic_embed
- topic_embed = Fabricate(:topic_embed, embed_url: "http://example.com/post/248")
- new_user = Fabricate(:user)
-
- topic_embed.post.revise(
- Discourse.system_user,
- { user_id: new_user.id },
- skip_validations: true,
- bypass_rate_limiter: true,
- )
-
- topic_embed
- end
- end
-end