From 29efdaf20ae98a5d8aa56322ae97a2d3bf3c3477 Mon Sep 17 00:00:00 2001 From: Molly Struve Date: Thu, 16 Jan 2020 09:31:11 -0500 Subject: [PATCH] Remove Comments::CreateIdCodeJob which is now done inline (#5536) --- app/jobs/comments/create_id_code_job.rb | 11 --------- spec/factories/comments.rb | 6 ----- spec/jobs/comments/create_id_code_job_spec.rb | 24 ------------------- .../comments/user_edits_a_comment_spec.rb | 1 - 4 files changed, 42 deletions(-) delete mode 100644 app/jobs/comments/create_id_code_job.rb delete mode 100644 spec/jobs/comments/create_id_code_job_spec.rb diff --git a/app/jobs/comments/create_id_code_job.rb b/app/jobs/comments/create_id_code_job.rb deleted file mode 100644 index a053b84c0..000000000 --- a/app/jobs/comments/create_id_code_job.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Comments - class CreateIdCodeJob < ApplicationJob - queue_as :comments_create_id_code - - def perform(comment_id) - comment = Comment.find_by(id: comment_id) - - comment&.update_column(:id_code, comment.id.to_s(26)) - end - end -end diff --git a/spec/factories/comments.rb b/spec/factories/comments.rb index 6b9d88457..3a9e3ca14 100644 --- a/spec/factories/comments.rb +++ b/spec/factories/comments.rb @@ -7,11 +7,5 @@ FactoryBot.define do factory :article_comment do association :commentable, factory: :article end - - trait :with_path do - after(:create) do |comment| - Comments::CreateIdCodeJob.perform_now(comment.id) - end - end end end diff --git a/spec/jobs/comments/create_id_code_job_spec.rb b/spec/jobs/comments/create_id_code_job_spec.rb deleted file mode 100644 index 1df509cc1..000000000 --- a/spec/jobs/comments/create_id_code_job_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require "rails_helper" - -RSpec.describe Comments::CreateIdCodeJob, type: :job do - include_examples "#enqueues_job", "comments_create_id_code", 1 - - describe "#perform_now" do - context "with comment" do - let_it_be(:article) { create(:article) } - let_it_be(:comment) { create(:comment, commentable: article) } - - it "creates an id code" do - described_class.perform_now(comment.id) - - expect(comment.reload.id_code).to eq(comment.id.to_s(26)) - end - end - - context "without comment" do - it "does not break" do - expect { described_class.perform_now(nil) }.not_to raise_error - end - end - end -end diff --git a/spec/system/comments/user_edits_a_comment_spec.rb b/spec/system/comments/user_edits_a_comment_spec.rb index f2db4e6c5..c93c029e0 100644 --- a/spec/system/comments/user_edits_a_comment_spec.rb +++ b/spec/system/comments/user_edits_a_comment_spec.rb @@ -6,7 +6,6 @@ RSpec.describe "Editing A Comment", type: :system, js: true do let(:new_comment_text) { Faker::Lorem.paragraph } let!(:comment) do create(:comment, - :with_path, commentable: article, user: user, body_markdown: Faker::Lorem.paragraph)