Fix: sentry issue for slack incoming files check (#4656)

Interpreter error for nil. any? added nil. present?

Fixes: https://sentry.io/share/issue/48c10d26490f4bdaab78c82244fcea98/
This commit is contained in:
Tejaswini Chile 2022-05-09 23:54:45 +05:30 committed by GitHub
parent 0eeab8c56c
commit f64cf85ab2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -37,7 +37,7 @@ class Integrations::Slack::IncomingMessageBuilder
if message.present? if message.present?
SUPPORTED_MESSAGE_TYPES.include?(message[:type]) && !attached_file_message? SUPPORTED_MESSAGE_TYPES.include?(message[:type]) && !attached_file_message?
else else
params[:event][:files].any? && !attached_file_message? params[:event][:files].present? && !attached_file_message?
end end
end end

View file

@ -61,6 +61,15 @@ describe Integrations::Slack::IncomingMessageBuilder do
expect(conversation.messages.count).to eql(messages_count) expect(conversation.messages.count).to eql(messages_count)
end end
it 'does not create message for invalid event type and event files is not present' do
messages_count = conversation.messages.count
message_with_attachments[:event][:files] = nil
builder = described_class.new(message_with_attachments)
allow(builder).to receive(:sender).and_return(nil)
builder.perform
expect(conversation.messages.count).to eql(messages_count)
end
it 'saves attachment if params files present' do it 'saves attachment if params files present' do
expect(hook).not_to eq nil expect(hook).not_to eq nil
messages_count = conversation.messages.count messages_count = conversation.messages.count