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

@@ -27,7 +27,7 @@ RSpec.describe AutomationRules::ActionService do
before do
allow(Messages::MessageBuilder).to receive(:new).and_return(message_builder)
rule.actions.delete_if { |a| a['action_name'] == 'send_message' }
rule.files.attach(io: File.open(Rails.root.join('spec/assets/avatar.png')), filename: 'avatar.png', content_type: 'image/png')
rule.files.attach(io: Rails.root.join('spec/assets/avatar.png').open, filename: 'avatar.png', content_type: 'image/png')
rule.save!
rule.actions << { action_name: 'send_attachment', action_params: [rule.files.first.blob_id] }
end
@@ -47,7 +47,7 @@ RSpec.describe AutomationRules::ActionService do
describe '#perform with send_webhook_event action' do
it 'will send webhook event' do
expect(rule.actions.map { |r| r['action_name'] }).to include('send_webhook_event')
expect(rule.actions.pluck('action_name')).to include('send_webhook_event')
expect(WebhookJob).to receive(:perform_later)
described_class.new(rule, account, conversation).perform
end
@@ -61,13 +61,13 @@ RSpec.describe AutomationRules::ActionService do
end
it 'will send message' do
expect(rule.actions.map { |r| r['action_name'] }).to include('send_message')
expect(rule.actions.pluck('action_name')).to include('send_message')
expect(message_builder).to receive(:perform)
described_class.new(rule, account, conversation).perform
end
it 'will not send message if conversation is a tweet' do
expect(rule.actions.map { |r| r['action_name'] }).to include('send_message')
expect(rule.actions.pluck('action_name')).to include('send_message')
twitter_inbox = create(:inbox, channel: create(:channel_twitter_profile, account: account))
conversation = create(:conversation, inbox: twitter_inbox, additional_attributes: { type: 'tweet' })
expect(message_builder).not_to receive(:perform)
@@ -102,6 +102,7 @@ RSpec.describe AutomationRules::ActionService do
allow(mailer).to receive(:conversation_transcript).with(conversation, 'agent1@example.com')
described_class.new(rule, account, conversation).perform
expect(mailer).to have_received(:conversation_transcript).exactly(3).times
end
it 'will send email to transcript to contacts' do
@@ -113,6 +114,7 @@ RSpec.describe AutomationRules::ActionService do
allow(mailer).to receive(:conversation_transcript).with(conversation, conversation.contact.email)
described_class.new(rule.reload, account, conversation).perform
expect(mailer).to have_received(:conversation_transcript).exactly(1).times
end
end
end