9f218fc184
A few things to note: - The IncomingEmail feature is now enabled even without a correctly-formatted sub-address - Message-ID for new thread mail are kept the same so that subsequent notifications to this thread are grouped in the thread by the email service that receives the notification (i.e. In-Reply-To of the answer == Message-ID of the first thread message) - To maximize our chance to be able to retrieve the reply key, we look for it in the In-Reply-To header and the References header - The pattern for the fallback reply message id is "reply-[key]@[gitlab_host]" - Improve docs thanks to Axil
51 lines
1.3 KiB
Ruby
51 lines
1.3 KiB
Ruby
require "spec_helper"
|
|
|
|
describe Gitlab::IncomingEmail, lib: true do
|
|
describe "self.enabled?" do
|
|
context "when reply by email is enabled" do
|
|
before do
|
|
stub_incoming_email_setting(enabled: true)
|
|
end
|
|
|
|
it 'returns true' do
|
|
expect(described_class.enabled?).to be_truthy
|
|
end
|
|
end
|
|
|
|
context "when reply by email is disabled" do
|
|
before do
|
|
stub_incoming_email_setting(enabled: false)
|
|
end
|
|
|
|
it "returns false" do
|
|
expect(described_class.enabled?).to be_falsey
|
|
end
|
|
end
|
|
end
|
|
|
|
context "self.reply_address" do
|
|
before do
|
|
stub_incoming_email_setting(address: "replies+%{key}@example.com")
|
|
end
|
|
|
|
it "returns the address with an interpolated reply key" do
|
|
expect(described_class.reply_address("key")).to eq("replies+key@example.com")
|
|
end
|
|
end
|
|
|
|
context "self.key_from_address" do
|
|
before do
|
|
stub_incoming_email_setting(address: "replies+%{key}@example.com")
|
|
end
|
|
|
|
it "returns reply key" do
|
|
expect(described_class.key_from_address("replies+key@example.com")).to eq("key")
|
|
end
|
|
end
|
|
|
|
context 'self.key_from_fallback_reply_message_id' do
|
|
it 'returns reply key' do
|
|
expect(described_class.key_from_fallback_reply_message_id('reply-key@localhost')).to eq('key')
|
|
end
|
|
end
|
|
end
|