chore: Enable the new Rubocop rules (#7122)

fixes: https://linear.app/chatwoot/issue/CW-1574/renable-the-disabled-rubocop-rules
This commit is contained in:
Sojan Jose
2023-05-19 14:37:10 +05:30
committed by GitHub
parent b988a01df3
commit 7ab7bac6bf
215 changed files with 609 additions and 608 deletions

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Account::ConversationsResolutionSchedulerJob, type: :job do
RSpec.describe Account::ConversationsResolutionSchedulerJob do
subject(:job) { described_class.perform_later }
let!(:account) { create(:account) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe AgentBots::CsmlJob, type: :job do
RSpec.describe AgentBots::CsmlJob do
it 'runs csml processor service' do
event = 'message.created'
message = create(:message)

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe AgentBots::WebhookJob, type: :job do
RSpec.describe AgentBots::WebhookJob do
include ActiveJob::TestHelper
subject(:job) { described_class.perform_later(url, payload) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Agents::DestroyJob, type: :job do
RSpec.describe Agents::DestroyJob do
subject(:job) { described_class.perform_later(account, user) }
let!(:account) { create(:account) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Avatar::AvatarFromGravatarJob, type: :job do
RSpec.describe Avatar::AvatarFromGravatarJob do
let(:avatarable) { create(:contact) }
let(:email) { 'test@test.com' }
let(:gravatar_url) { "https://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email)}?d=404" }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Avatar::AvatarFromUrlJob, type: :job do
RSpec.describe Avatar::AvatarFromUrlJob do
let(:avatarable) { create(:contact) }
let(:avatar_url) { 'https://example.com/avatar.png' }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe BulkActionsJob, type: :job do
RSpec.describe BulkActionsJob do
params = {
type: 'Conversation',
fields: { status: 'snoozed' },

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Campaigns::TriggerOneoffCampaignJob, type: :job do
RSpec.describe Campaigns::TriggerOneoffCampaignJob do
let(:account) { create(:account) }
let!(:twilio_sms) { create(:channel_twilio_sms) }
let!(:twilio_inbox) { create(:inbox, channel: twilio_sms) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Channels::Whatsapp::TemplatesSyncJob, type: :job do
RSpec.describe Channels::Whatsapp::TemplatesSyncJob do
let(:channel_whatsapp) { create(:channel_whatsapp, sync_templates: false) }
it 'enqueues the job' do

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Channels::Whatsapp::TemplatesSyncSchedulerJob, type: :job do
RSpec.describe Channels::Whatsapp::TemplatesSyncSchedulerJob do
it 'enqueues the job' do
expect { described_class.perform_later }.to have_enqueued_job(described_class)
.on_queue('low')

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Conversations::ReopenSnoozedConversationsJob, type: :job do
RSpec.describe Conversations::ReopenSnoozedConversationsJob do
let!(:snoozed_till_5_minutes_ago) { create(:conversation, status: :snoozed, snoozed_until: 5.minutes.ago) }
let!(:snoozed_till_tomorrow) { create(:conversation, status: :snoozed, snoozed_until: 1.day.from_now) }
let!(:snoozed_indefinitely) { create(:conversation, status: :snoozed) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Conversations::ResolutionJob, type: :job do
RSpec.describe Conversations::ResolutionJob do
subject(:job) { described_class.perform_later(account) }
let!(:account) { create(:account) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe DataImportJob, type: :job do
RSpec.describe DataImportJob do
subject(:job) { described_class.perform_later(data_import) }
let!(:data_import) { create(:data_import) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe DeleteObjectJob, type: :job do
RSpec.describe DeleteObjectJob do
subject(:job) { described_class.perform_later(account) }
let(:account) { create(:account) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe EventDispatcherJob, type: :job do
RSpec.describe EventDispatcherJob do
subject(:job) { described_class.perform_later(event_name, timestamp, event_data) }
let!(:conversation) { create(:conversation) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe HookJob, type: :job do
RSpec.describe HookJob do
subject(:job) { described_class.perform_later(hook, event_name, event_data) }
let(:account) { create(:account) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Inboxes::FetchImapEmailInboxesJob, type: :job do
RSpec.describe Inboxes::FetchImapEmailInboxesJob do
let(:account) { create(:account) }
let(:imap_email_channel) do
create(:channel_email, imap_enabled: true, imap_address: 'imap.gmail.com', imap_port: 993, imap_login: 'imap@gmail.com',

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Inboxes::FetchImapEmailsJob, type: :job do
RSpec.describe Inboxes::FetchImapEmailsJob do
include ActionMailbox::TestHelper
let(:account) { create(:account) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Inboxes::SyncWidgetPreChatCustomFieldsJob, type: :job do
RSpec.describe Inboxes::SyncWidgetPreChatCustomFieldsJob do
pre_chat_fields = [{
'label' => 'Developer Id',
'name' => 'developer_id'

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Inboxes::UpdateWidgetPreChatCustomFieldsJob, type: :job do
RSpec.describe Inboxes::UpdateWidgetPreChatCustomFieldsJob do
pre_chat_fields = [{
'label' => 'Developer Id',
'name' => 'developer_id'

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Internal::CheckNewVersionsJob, type: :job do
RSpec.describe Internal::CheckNewVersionsJob do
subject(:job) { described_class.perform_now }
it 'updates the latest chatwoot version in redis' do
@@ -9,6 +9,6 @@ RSpec.describe Internal::CheckNewVersionsJob, type: :job do
allow(ChatwootHub).to receive(:latest_version).and_return(version)
job
expect(ChatwootHub).to have_received(:latest_version)
expect(::Redis::Alfred.get(::Redis::Alfred::LATEST_CHATWOOT_VERSION)).to eq version
expect(Redis::Alfred.get(Redis::Alfred::LATEST_CHATWOOT_VERSION)).to eq version
end
end

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Labels::UpdateJob, type: :job do
RSpec.describe Labels::UpdateJob do
subject(:job) { described_class.perform_later(new_label_title, old_label_title, account_id) }
let(:new_label_title) { 'new-title' }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Migration::ConversationsFirstReplySchedulerJob, type: :job do
RSpec.describe Migration::ConversationsFirstReplySchedulerJob do
subject(:job) { described_class.perform_later }
let!(:account) { create(:account) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe SendReplyJob, type: :job do
RSpec.describe SendReplyJob do
subject(:job) { described_class.perform_later(message) }
let(:message) { create(:message) }
@@ -33,8 +33,8 @@ RSpec.describe SendReplyJob, type: :job do
twitter_channel = create(:channel_twitter_profile)
twitter_inbox = create(:inbox, channel: twitter_channel)
message = create(:message, conversation: create(:conversation, inbox: twitter_inbox))
allow(::Twitter::SendOnTwitterService).to receive(:new).with(message: message).and_return(process_service)
expect(::Twitter::SendOnTwitterService).to receive(:new).with(message: message)
allow(Twitter::SendOnTwitterService).to receive(:new).with(message: message).and_return(process_service)
expect(Twitter::SendOnTwitterService).to receive(:new).with(message: message)
expect(process_service).to receive(:perform)
described_class.perform_now(message.id)
end
@@ -42,8 +42,8 @@ RSpec.describe SendReplyJob, type: :job do
it 'calls ::Twilio::SendOnTwilioService when its twilio message' do
twilio_channel = create(:channel_twilio_sms)
message = create(:message, conversation: create(:conversation, inbox: twilio_channel.inbox))
allow(::Twilio::SendOnTwilioService).to receive(:new).with(message: message).and_return(process_service)
expect(::Twilio::SendOnTwilioService).to receive(:new).with(message: message)
allow(Twilio::SendOnTwilioService).to receive(:new).with(message: message).and_return(process_service)
expect(Twilio::SendOnTwilioService).to receive(:new).with(message: message)
expect(process_service).to receive(:perform)
described_class.perform_now(message.id)
end
@@ -51,8 +51,8 @@ RSpec.describe SendReplyJob, type: :job do
it 'calls ::Telegram::SendOnTelegramService when its telegram message' do
telegram_channel = create(:channel_telegram)
message = create(:message, conversation: create(:conversation, inbox: telegram_channel.inbox))
allow(::Telegram::SendOnTelegramService).to receive(:new).with(message: message).and_return(process_service)
expect(::Telegram::SendOnTelegramService).to receive(:new).with(message: message)
allow(Telegram::SendOnTelegramService).to receive(:new).with(message: message).and_return(process_service)
expect(Telegram::SendOnTelegramService).to receive(:new).with(message: message)
expect(process_service).to receive(:perform)
described_class.perform_now(message.id)
end
@@ -60,8 +60,8 @@ RSpec.describe SendReplyJob, type: :job do
it 'calls ::Line:SendOnLineService when its line message' do
line_channel = create(:channel_line)
message = create(:message, conversation: create(:conversation, inbox: line_channel.inbox))
allow(::Line::SendOnLineService).to receive(:new).with(message: message).and_return(process_service)
expect(::Line::SendOnLineService).to receive(:new).with(message: message)
allow(Line::SendOnLineService).to receive(:new).with(message: message).and_return(process_service)
expect(Line::SendOnLineService).to receive(:new).with(message: message)
expect(process_service).to receive(:perform)
described_class.perform_now(message.id)
end
@@ -70,8 +70,8 @@ RSpec.describe SendReplyJob, type: :job do
stub_request(:post, 'https://waba.360dialog.io/v1/configs/webhook')
whatsapp_channel = create(:channel_whatsapp, sync_templates: false)
message = create(:message, conversation: create(:conversation, inbox: whatsapp_channel.inbox))
allow(::Whatsapp::SendOnWhatsappService).to receive(:new).with(message: message).and_return(process_service)
expect(::Whatsapp::SendOnWhatsappService).to receive(:new).with(message: message)
allow(Whatsapp::SendOnWhatsappService).to receive(:new).with(message: message).and_return(process_service)
expect(Whatsapp::SendOnWhatsappService).to receive(:new).with(message: message)
expect(process_service).to receive(:perform)
described_class.perform_now(message.id)
end
@@ -79,8 +79,8 @@ RSpec.describe SendReplyJob, type: :job do
it 'calls ::Sms::SendOnSmsService when its sms message' do
sms_channel = create(:channel_sms)
message = create(:message, conversation: create(:conversation, inbox: sms_channel.inbox))
allow(::Sms::SendOnSmsService).to receive(:new).with(message: message).and_return(process_service)
expect(::Sms::SendOnSmsService).to receive(:new).with(message: message)
allow(Sms::SendOnSmsService).to receive(:new).with(message: message).and_return(process_service)
expect(Sms::SendOnSmsService).to receive(:new).with(message: message)
expect(process_service).to receive(:perform)
described_class.perform_now(message.id)
end

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe TriggerScheduledItemsJob, type: :job do
RSpec.describe TriggerScheduledItemsJob do
subject(:job) { described_class.perform_later }
let(:account) { create(:account) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe WebhookJob, type: :job do
RSpec.describe WebhookJob do
include ActiveJob::TestHelper
subject(:job) { described_class.perform_later(url, payload) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Webhooks::FacebookEventsJob, type: :job do
RSpec.describe Webhooks::FacebookEventsJob do
subject(:job) { described_class.perform_later(params) }
let!(:params) { { test: 'test' } }
@@ -15,11 +15,11 @@ RSpec.describe Webhooks::FacebookEventsJob, type: :job do
it 'calls MessagePArsed and do message create' do
parser = double
creator = double
allow(::Integrations::Facebook::MessageParser).to receive(:new).and_return(parser)
allow(::Integrations::Facebook::MessageCreator).to receive(:new).and_return(creator)
allow(Integrations::Facebook::MessageParser).to receive(:new).and_return(parser)
allow(Integrations::Facebook::MessageCreator).to receive(:new).and_return(creator)
allow(creator).to receive(:perform).and_return(true)
expect(::Integrations::Facebook::MessageParser).to receive(:new).with(params)
expect(::Integrations::Facebook::MessageCreator).to receive(:new).with(parser)
expect(Integrations::Facebook::MessageParser).to receive(:new).with(params)
expect(Integrations::Facebook::MessageCreator).to receive(:new).with(parser)
expect(creator).to receive(:perform)
described_class.perform_now(params)
end

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Webhooks::LineEventsJob, type: :job do
RSpec.describe Webhooks::LineEventsJob do
subject(:job) { described_class.perform_later(params: params) }
let!(:line_channel) { create(:channel_line) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Webhooks::SmsEventsJob, type: :job do
RSpec.describe Webhooks::SmsEventsJob do
subject(:job) { described_class.perform_later(params) }
let!(:sms_channel) { create(:channel_sms) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Webhooks::TelegramEventsJob, type: :job do
RSpec.describe Webhooks::TelegramEventsJob do
subject(:job) { described_class.perform_later(params) }
let!(:telegram_channel) { create(:channel_telegram) }

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Webhooks::WhatsappEventsJob, type: :job do
RSpec.describe Webhooks::WhatsappEventsJob do
subject(:job) { described_class }
let(:channel) { create(:channel_whatsapp, provider: 'whatsapp_cloud', sync_templates: false, validate_provider_config: false) }