diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/lib/gitlab/email | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/lib/gitlab/email')
4 files changed, 105 insertions, 3 deletions
diff --git a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb index 59b87c5d8e7..9ff395070ea 100644 --- a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb @@ -62,7 +62,7 @@ RSpec.describe Gitlab::Email::Handler::CreateNoteHandler do end it 'does not raise a UserNotFoundError' do - expect { receiver.execute }.not_to raise_error(Gitlab::Email::UserNotFoundError) + expect { receiver.execute }.not_to raise_error end end end @@ -71,7 +71,7 @@ RSpec.describe Gitlab::Email::Handler::CreateNoteHandler do let(:original_recipient) { User.support_bot } it 'does not raise a UserNotFoundError' do - expect { receiver.execute }.not_to raise_error(Gitlab::Email::UserNotFoundError) + expect { receiver.execute }.not_to raise_error end end end diff --git a/spec/lib/gitlab/email/message/build_ios_app_guide_spec.rb b/spec/lib/gitlab/email/message/build_ios_app_guide_spec.rb new file mode 100644 index 00000000000..3089f955252 --- /dev/null +++ b/spec/lib/gitlab/email/message/build_ios_app_guide_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Email::Message::BuildIosAppGuide do + subject(:message) { described_class.new } + + before do + allow(Gitlab).to receive(:com?) { true } + end + + it 'contains the correct message', :aggregate_failures do + expect(message.subject_line).to eq 'Get set up to build for iOS' + expect(message.title).to eq "Building for iOS? We've got you covered." + expect(message.body_line1).to eq "Want to get your iOS app up and running, including " \ + "publishing all the way to TestFlight? Follow our guide to set up GitLab and fastlane to publish iOS apps to " \ + "the App Store." + expect(message.cta_text).to eq 'Learn how to build for iOS' + expect(message.cta2_text).to eq 'Watch iOS building in action.' + expect(message.logo_path).to eq 'mailers/in_product_marketing/create-0.png' + expect(message.unsubscribe).to include('%tag_unsubscribe_url%') + end +end diff --git a/spec/lib/gitlab/email/message/in_product_marketing/base_spec.rb b/spec/lib/gitlab/email/message/in_product_marketing/base_spec.rb index 8bd873cf008..dfa18c27d5e 100644 --- a/spec/lib/gitlab/email/message/in_product_marketing/base_spec.rb +++ b/spec/lib/gitlab/email/message/in_product_marketing/base_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Gitlab::Email::Message::InProductMarketing::Base do let(:series) { 0 } it 'does not raise error' do - expect { subject }.not_to raise_error(ArgumentError) + expect { subject }.not_to raise_error end end end diff --git a/spec/lib/gitlab/email/message/in_product_marketing/helper_spec.rb b/spec/lib/gitlab/email/message/in_product_marketing/helper_spec.rb new file mode 100644 index 00000000000..3c0d83d0f9e --- /dev/null +++ b/spec/lib/gitlab/email/message/in_product_marketing/helper_spec.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Email::Message::InProductMarketing::Helper do + describe 'unsubscribe_message' do + include Gitlab::Routing + + let(:dummy_class_with_helper) do + Class.new do + include Gitlab::Email::Message::InProductMarketing::Helper + include Gitlab::Routing + + def initialize(format = :html) + @format = format + end + + def default_url_options + {} + end + + attr_accessor :format + end + end + + let(:format) { :html } + + subject(:class_with_helper) { dummy_class_with_helper.new(format) } + + context 'gitlab.com' do + before do + allow(Gitlab).to receive(:com?) { true } + end + + context 'format is HTML' do + it 'returns the correct HTML' do + message = "If you no longer wish to receive marketing emails from us, " \ + "you may <a href=\"%tag_unsubscribe_url%\">unsubscribe</a> at any time." + expect(class_with_helper.unsubscribe_message).to match message + end + end + + context 'format is text' do + let(:format) { :text } + + it 'returns the correct string' do + message = "If you no longer wish to receive marketing emails from us, " \ + "you may unsubscribe (%tag_unsubscribe_url%) at any time." + expect(class_with_helper.unsubscribe_message.squish).to match message + end + end + end + + context 'self-managed' do + context 'format is HTML' do + it 'returns the correct HTML' do + preferences_link = "http://example.com/preferences" + message = "To opt out of these onboarding emails, " \ + "<a href=\"#{profile_notifications_url}\">unsubscribe</a>. " \ + "If you don't want to receive marketing emails directly from GitLab, #{preferences_link}." + expect(class_with_helper.unsubscribe_message(preferences_link)) + .to match message + end + end + + context 'format is text' do + let(:format) { :text } + + it 'returns the correct string' do + preferences_link = "http://example.com/preferences" + message = "To opt out of these onboarding emails, " \ + "unsubscribe (#{profile_notifications_url}). " \ + "If you don't want to receive marketing emails directly from GitLab, #{preferences_link}." + expect(class_with_helper.unsubscribe_message(preferences_link).squish).to match message + end + end + end + end +end |