debian-mirror-gitlab/spec/lib/gitlab/incoming_email_spec.rb

35 lines
990 B
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
2023-01-13 00:05:48 +05:30
require 'spec_helper'
2015-09-25 12:07:36 +05:30
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::IncomingEmail do
2023-01-13 00:05:48 +05:30
let(:setting_name) { :incoming_email }
2015-09-25 12:07:36 +05:30
2023-01-13 00:05:48 +05:30
it_behaves_like 'common email methods'
2015-09-25 12:07:36 +05:30
2023-01-13 00:05:48 +05:30
describe 'self.key_from_address' do
2017-08-17 22:00:37 +05:30
before do
stub_incoming_email_setting(address: 'replies+%{key}@example.com')
end
2015-09-25 12:07:36 +05:30
it "returns reply key" do
expect(described_class.key_from_address("replies+key@example.com")).to eq("key")
end
2018-11-08 19:23:39 +05:30
it 'does not match emails with extra bits' do
expect(described_class.key_from_address('somereplies+somekey@example.com.someotherdomain.com')).to be nil
end
2020-04-08 14:13:33 +05:30
context 'when a custom wildcard address is used' do
let(:wildcard_address) { 'custom.address+%{key}@example.com' }
it 'finds key if email matches address pattern' do
key = described_class.key_from_address(
'custom.address+foo@example.com', wildcard_address: wildcard_address
)
expect(key).to eq('foo')
end
end
2015-09-25 12:07:36 +05:30
end
end