BigW Consortium Gitlab

incoming_email_spec.rb 1.28 KB
Newer Older
1 2
require "spec_helper"

Douwe Maan committed
3
describe Gitlab::IncomingEmail, lib: true do
4 5 6 7 8 9
  describe "self.enabled?" do
    context "when reply by email is enabled" do
      before do
        stub_incoming_email_setting(enabled: true)
      end

10 11
      it 'returns true' do
        expect(described_class.enabled?).to be_truthy
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
      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
45

46
  context 'self.key_from_fallback_message_id' do
47
    it 'returns reply key' do
48
      expect(described_class.key_from_fallback_message_id('reply-key@localhost')).to eq('key')
49 50
    end
  end
51
end