Welcome to mirror list, hosted at ThFree Co, Russian Federation.

custom_email_spec.rb « service_desk « email « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bba1ca1c8becb9e43d74af90a103e98d9a5df41e (plain)
1
2
3
4
5
6
7
8
9
10
11
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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Email::ServiceDesk::CustomEmail, feature_category: :service_desk do
  let(:reply_key) { 'b7721fc7e8419911a8bea145236a0519' }
  let(:custom_email) { 'support@example.com' }
  let(:email_with_reply_key) { 'support+b7721fc7e8419911a8bea145236a0519@example.com' }

  describe '.reply_address' do
    let_it_be(:project) { create(:project) }

    subject(:reply_address) { described_class.reply_address(nil, nil) }

    it { is_expected.to be nil }

    context 'with reply key' do
      subject(:reply_address) { described_class.reply_address(nil, reply_key) }

      it { is_expected.to be nil }

      context 'with issue' do
        let_it_be(:issue) { create(:issue, project: project) }

        subject(:reply_address) { described_class.reply_address(issue, reply_key) }

        it { is_expected.to be nil }

        context 'with service_desk_setting and custom email' do
          let!(:service_desk_setting) { create(:service_desk_setting, custom_email: custom_email, project: project) }

          it { is_expected.to eq(email_with_reply_key) }
        end
      end
    end
  end
end