diff options
Diffstat (limited to 'spec/models/project_services/chat_message/base_message_spec.rb')
-rw-r--r-- | spec/models/project_services/chat_message/base_message_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/models/project_services/chat_message/base_message_spec.rb b/spec/models/project_services/chat_message/base_message_spec.rb new file mode 100644 index 00000000000..8f80cf0b074 --- /dev/null +++ b/spec/models/project_services/chat_message/base_message_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe ChatMessage::BaseMessage do + let(:base_message) { described_class.new(args) } + let(:args) { { project_url: 'https://gitlab-domain.com' } } + + describe '#fallback' do + subject { base_message.fallback } + + before do + allow(base_message).to receive(:message).and_return(message) + end + + context 'without relative links' do + let(:message) { 'Just another *markdown* message' } + + it { is_expected.to eq(message) } + end + + context 'with relative links' do + let(:message) { 'Check this out ![Screenshot1](/uploads/Screenshot1.png)' } + + it { is_expected.to eq('Check this out https://gitlab-domain.com/uploads/Screenshot1.png') } + end + + context 'with multiple relative links' do + let(:message) { 'Check this out ![Screenshot1](/uploads/Screenshot1.png). And this ![Screenshot2](/uploads/Screenshot2.png)' } + + it { is_expected.to eq('Check this out https://gitlab-domain.com/uploads/Screenshot1.png. And this https://gitlab-domain.com/uploads/Screenshot2.png') } + end + end +end |