From 50551213615758eb67ded93cf61d661fd6a3e8ce Mon Sep 17 00:00:00 2001 From: Alain Mauri Date: Wed, 8 Jan 2020 21:33:40 +0000 Subject: [PATCH] Remove Chat Channels Index Job (#5409) [deploy] --- app/jobs/chat_channels/index_job.rb | 14 --------- app/models/message.rb | 2 -- spec/jobs/chat_channels/index_job_spec.rb | 35 ----------------------- 3 files changed, 51 deletions(-) delete mode 100644 app/jobs/chat_channels/index_job.rb delete mode 100644 spec/jobs/chat_channels/index_job_spec.rb diff --git a/app/jobs/chat_channels/index_job.rb b/app/jobs/chat_channels/index_job.rb deleted file mode 100644 index 6f4740bb5..000000000 --- a/app/jobs/chat_channels/index_job.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module ChatChannels - class IndexJob < ApplicationJob - queue_as :chat_channels_index - - def perform(chat_channel_id:) - chat_channel = ChatChannel.find_by(id: chat_channel_id) - return unless chat_channel - - chat_channel.index! - end - end -end diff --git a/app/models/message.rb b/app/models/message.rb index 50ecc7a1b..4c53885d9 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -29,8 +29,6 @@ class Message < ApplicationRecord chat_channel.touch(:last_message_at) chat_channel.index! chat_channel.chat_channel_memberships.reindex! - - ChatChannels::IndexJob.perform_later(chat_channel_id: chat_channel.id) end def update_all_has_unopened_messages_statuses diff --git a/spec/jobs/chat_channels/index_job_spec.rb b/spec/jobs/chat_channels/index_job_spec.rb deleted file mode 100644 index 5338d4bdf..000000000 --- a/spec/jobs/chat_channels/index_job_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -RSpec.describe ChatChannels::IndexJob, type: :job do - include_examples "#enqueues_job", "chat_channels_index", chat_channel_id: 1 - - describe "#perform_now" do - let_it_be(:chat_channel) { double } - let_it_be(:chat_channel_id) { 1 } - - context "when chat_channel is found" do - before do - allow(ChatChannel).to receive(:find_by).with(id: chat_channel_id).and_return(chat_channel) - allow(chat_channel).to receive(:index!) - end - - it "calls index" do - described_class.perform_now(chat_channel_id: chat_channel_id) - - expect(chat_channel).to have_received(:index!) - end - end - - context "when chat_channel is not found" do - before do - allow(ChatChannel).to receive(:find_by).with(id: chat_channel_id).and_return(nil) - end - - it "doesn't fail" do - expect { described_class.perform_now(chat_channel_id: chat_channel_id) }.not_to raise_error - end - end - end -end