diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-15 15:13:49 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-15 15:13:49 +0000 |
commit | 229395d3af51cd46a9179f2eba142c027d08b208 (patch) | |
tree | 56efbeeb1bb9bf8e6f68174436cacd5c2d20fca4 /spec/initializers | |
parent | 3107fe7203685580829c7d6ca56161e13acb83eb (diff) | |
download | gitlab-ce-229395d3af51cd46a9179f2eba142c027d08b208.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/initializers')
-rw-r--r-- | spec/initializers/microsoft_graph_mailer_spec.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/initializers/microsoft_graph_mailer_spec.rb b/spec/initializers/microsoft_graph_mailer_spec.rb new file mode 100644 index 00000000000..fbe667e34fe --- /dev/null +++ b/spec/initializers/microsoft_graph_mailer_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'microsoft_graph_mailer initializer for GitLab' do + let(:microsoft_graph_setting) do + { + user_id: SecureRandom.hex, + tenant: SecureRandom.hex, + client_id: SecureRandom.hex, + client_secret: SecureRandom.hex, + azure_ad_endpoint: 'https://test-azure_ad_endpoint', + graph_endpoint: 'https://test-graph_endpoint' + } + end + + def load_microsoft_graph_mailer_initializer + load Rails.root.join('config/initializers/microsoft_graph_mailer.rb') + end + + context 'when microsoft_graph_mailer is enabled' do + before do + stub_microsoft_graph_mailer_setting(microsoft_graph_setting.merge(enabled: true)) + end + + it 'configures ActionMailer' do + previous_delivery_method = ActionMailer::Base.delivery_method + previous_microsoft_graph_settings = ActionMailer::Base.microsoft_graph_settings + + load_microsoft_graph_mailer_initializer + + expect(ActionMailer::Base.delivery_method).to eq(:microsoft_graph) + expect(ActionMailer::Base.microsoft_graph_settings).to eq(microsoft_graph_setting) + ensure + ActionMailer::Base.delivery_method = previous_delivery_method + ActionMailer::Base.microsoft_graph_settings = previous_microsoft_graph_settings + end + end + + context 'when microsoft_graph_mailer is disabled' do + before do + stub_microsoft_graph_mailer_setting(microsoft_graph_setting.merge(enabled: false)) + end + + it 'does not configure ActionMailer' do + previous_delivery_method = ActionMailer::Base.delivery_method + previous_microsoft_graph_settings = ActionMailer::Base.microsoft_graph_settings + + load_microsoft_graph_mailer_initializer + + expect(previous_microsoft_graph_settings).not_to eq(:microsoft_graph) + expect(ActionMailer::Base.delivery_method).to eq(previous_delivery_method) + expect(ActionMailer::Base.microsoft_graph_settings).to eq(previous_microsoft_graph_settings) + end + end +end |