Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
81 lines
2.8 KiB
Ruby
81 lines
2.8 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe MailboxHelper do
|
|
include ActionMailbox::TestHelper
|
|
|
|
# Setup anonymous class
|
|
let(:mailbox_helper_obj) do
|
|
Class.new do
|
|
include MailboxHelper
|
|
attr_accessor :conversation, :processed_mail
|
|
|
|
def initialize(conversation, processed_mail)
|
|
@conversation = conversation
|
|
@processed_mail = processed_mail
|
|
end
|
|
end
|
|
end
|
|
|
|
let(:mail) { create_inbound_email_from_fixture('welcome.eml').mail }
|
|
let(:processed_mail) { MailPresenter.new(mail) }
|
|
let(:conversation) { create(:conversation) }
|
|
let(:dummy_message) { create(:message) }
|
|
|
|
describe '#create_message' do
|
|
before do
|
|
create_list(:message, 5, conversation: conversation)
|
|
end
|
|
|
|
context 'when message already exist' do
|
|
it 'creates a new message' do
|
|
helper_instance = mailbox_helper_obj.new(conversation, processed_mail)
|
|
|
|
expect(conversation.messages).to receive(:find_by).with(source_id: processed_mail.message_id).and_return(dummy_message)
|
|
expect(conversation.messages).not_to receive(:create!)
|
|
|
|
helper_instance.send(:create_message)
|
|
end
|
|
end
|
|
|
|
context 'when message does not exist' do
|
|
it 'creates a new message' do
|
|
helper_instance = mailbox_helper_obj.new(conversation, processed_mail)
|
|
|
|
expect(conversation.messages).to receive(:find_by).with(source_id: processed_mail.message_id).and_return(nil)
|
|
expect(conversation.messages).to receive(:create!)
|
|
|
|
helper_instance.send(:create_message)
|
|
end
|
|
end
|
|
end
|
|
|
|
describe '#embed_plain_text_email_with_inline_image' do
|
|
let(:mail_attachment) do
|
|
{
|
|
original: OpenStruct.new(filename: 'image.png'),
|
|
blob: get_blob_for('spec/assets/avatar.png', 'image/png')
|
|
}
|
|
end
|
|
|
|
let(:helper_instance) { mailbox_helper_obj.new(conversation, processed_mail) }
|
|
|
|
it 'replaces the image tag in the text content' do
|
|
helper_instance.instance_variable_set(:@text_content, 'Hello [image: image.png] World')
|
|
helper_instance.send(:embed_plain_text_email_with_inline_image, mail_attachment)
|
|
|
|
text_content = helper_instance.instance_variable_get(:@text_content)
|
|
|
|
expect(text_content).to include(Rails.application.routes.url_helpers.url_for(mail_attachment[:blob]))
|
|
expect(text_content).not_to include('[image: avatar.png]')
|
|
end
|
|
|
|
it 'replaces the image tag in the text content even if there is not tag to replace' do
|
|
helper_instance.instance_variable_set(:@text_content, 'Hello World')
|
|
helper_instance.send(:embed_plain_text_email_with_inline_image, mail_attachment)
|
|
|
|
text_content = helper_instance.instance_variable_get(:@text_content)
|
|
expect(text_content).to include(Rails.application.routes.url_helpers.url_for(mail_attachment[:blob]))
|
|
end
|
|
end
|
|
end
|