summaryrefslogtreecommitdiff
path: root/spec/mailers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 15:40:28 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 15:40:28 +0000
commitb595cb0c1dec83de5bdee18284abe86614bed33b (patch)
tree8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/mailers
parent2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff)
downloadgitlab-ce-b595cb0c1dec83de5bdee18284abe86614bed33b.tar.gz
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/mailers')
-rw-r--r--spec/mailers/devise_mailer_spec.rb30
-rw-r--r--spec/mailers/emails/admin_notification_spec.rb18
-rw-r--r--spec/mailers/emails/in_product_marketing_spec.rb8
-rw-r--r--spec/mailers/emails/profile_spec.rb8
-rw-r--r--spec/mailers/notify_spec.rb17
5 files changed, 60 insertions, 21 deletions
diff --git a/spec/mailers/devise_mailer_spec.rb b/spec/mailers/devise_mailer_spec.rb
index 2634d7c722b..360eb827927 100644
--- a/spec/mailers/devise_mailer_spec.rb
+++ b/spec/mailers/devise_mailer_spec.rb
@@ -126,4 +126,34 @@ RSpec.describe DeviseMailer do
is_expected.to have_link("Reset password", href: "#{Gitlab.config.gitlab.url}/users/password/edit?reset_password_token=faketoken")
end
end
+
+ describe '#email_changed' do
+ subject { described_class.email_changed(user, {}) }
+
+ let_it_be(:user) { create(:user) }
+
+ it_behaves_like 'an email sent from GitLab'
+
+ it 'is sent to the user' do
+ is_expected.to deliver_to user.email
+ end
+
+ it 'has the correct subject' do
+ is_expected.to have_subject 'Email Changed'
+ end
+
+ it 'greets the user' do
+ is_expected.to have_body_text /Hello, #{user.name}!/
+ end
+
+ context "email contains updated id" do
+ before do
+ user.update!(email: "new_email@test.com")
+ end
+
+ it 'includes changed email id' do
+ is_expected.to have_body_text /email is being changed to new_email@test.com./
+ end
+ end
+ end
end
diff --git a/spec/mailers/emails/admin_notification_spec.rb b/spec/mailers/emails/admin_notification_spec.rb
index a233be86a83..1b770d6d4a2 100644
--- a/spec/mailers/emails/admin_notification_spec.rb
+++ b/spec/mailers/emails/admin_notification_spec.rb
@@ -18,12 +18,14 @@ RSpec.describe Emails::AdminNotification do
let(:max_project_downloads) { 5 }
let(:time_period) { 600 }
+ let(:group) { nil }
subject do
Notify.user_auto_banned_email(
admin.id, user.id,
max_project_downloads: max_project_downloads,
- within_seconds: time_period
+ within_seconds: time_period,
+ group: group
)
end
@@ -45,6 +47,10 @@ RSpec.describe Emails::AdminNotification do
is_expected.to have_body_text user.name
end
+ it 'includes the scope of the ban' do
+ is_expected.to have_body_text "banned from your GitLab instance"
+ end
+
it 'includes the reason' do
is_expected.to have_body_text "due to them downloading more than 5 project repositories within 10 minutes"
end
@@ -58,7 +64,15 @@ RSpec.describe Emails::AdminNotification do
end
it 'includes the email reason' do
- is_expected.to have_body_text "You're receiving this email because of your account on localhost"
+ is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost<\/a>}
+ end
+
+ context 'when scoped to a group' do
+ let(:group) { create(:group) }
+
+ it 'includes the scope of the ban' do
+ is_expected.to have_body_text "banned from your group (#{group.name})"
+ end
end
end
end
diff --git a/spec/mailers/emails/in_product_marketing_spec.rb b/spec/mailers/emails/in_product_marketing_spec.rb
index 7f3896a3d51..7c21e161ffe 100644
--- a/spec/mailers/emails/in_product_marketing_spec.rb
+++ b/spec/mailers/emails/in_product_marketing_spec.rb
@@ -65,7 +65,6 @@ RSpec.describe Emails::InProductMarketing do
:team | 0
:team | 1
:team | 2
- :experience | 0
:team_short | 0
:trial_short | 0
:admin_verify | 0
@@ -83,12 +82,7 @@ RSpec.describe Emails::InProductMarketing do
is_expected.to have_subject(message.subject_line)
is_expected.to have_body_text(message.title)
is_expected.to have_body_text(message.subtitle)
-
- if track == :experience
- is_expected.to have_body_text(CGI.unescapeHTML(message.feedback_link(1)))
- else
- is_expected.to have_body_text(CGI.unescapeHTML(message.cta_link))
- end
+ is_expected.to have_body_text(CGI.unescapeHTML(message.cta_link))
if track =~ /(create|verify)/
is_expected.to have_body_text(message.invite_text)
diff --git a/spec/mailers/emails/profile_spec.rb b/spec/mailers/emails/profile_spec.rb
index f4483f7e8f5..09ed27eb90f 100644
--- a/spec/mailers/emails/profile_spec.rb
+++ b/spec/mailers/emails/profile_spec.rb
@@ -151,7 +151,7 @@ RSpec.describe Emails::Profile do
end
it 'includes the email reason' do
- is_expected.to have_body_text /You're receiving this email because of your account on localhost/
+ is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost<\/a>}
end
end
end
@@ -187,7 +187,7 @@ RSpec.describe Emails::Profile do
end
it 'includes the email reason' do
- is_expected.to have_body_text /You're receiving this email because of your account on localhost/
+ is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost<\/a>}
end
context 'with User does not exist' do
@@ -222,7 +222,7 @@ RSpec.describe Emails::Profile do
end
it 'includes the email reason' do
- is_expected.to have_body_text /You're receiving this email because of your account on localhost/
+ is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost<\/a>}
end
end
@@ -266,7 +266,7 @@ RSpec.describe Emails::Profile do
end
shared_examples 'includes the email reason' do
- it { is_expected.to have_body_text /You're receiving this email because of your account on localhost/ }
+ it { is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost<\/a>} }
end
shared_examples 'valid use case' do
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index a9796c28870..8beb54bca4d 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe Notify do
include EmailSpec::Helpers
include EmailSpec::Matchers
include EmailHelpers
+ include EmailsHelper
include RepoHelpers
include MembersHelper
@@ -396,7 +397,7 @@ RSpec.describe Notify do
end
end
- context 'when sent with a reason' do
+ context 'when sent with a reason', type: :helper do
subject { described_class.reassigned_merge_request_email(recipient.id, merge_request.id, [previous_assignee.id], current_user.id, NotificationReason::ASSIGNED) }
it_behaves_like 'appearance header and footer enabled'
@@ -407,15 +408,15 @@ RSpec.describe Notify do
end
it 'includes the reason in the footer' do
- text = EmailsHelper.instance_method(:notification_reason_text).bind(self).call(NotificationReason::ASSIGNED)
+ text = EmailsHelper.instance_method(:notification_reason_text).bind(self).call(reason: NotificationReason::ASSIGNED, format: :html)
is_expected.to have_body_text(text)
new_subject = described_class.reassigned_merge_request_email(recipient.id, merge_request.id, [previous_assignee.id], current_user.id, NotificationReason::MENTIONED)
- text = EmailsHelper.instance_method(:notification_reason_text).bind(self).call(NotificationReason::MENTIONED)
+ text = EmailsHelper.instance_method(:notification_reason_text).bind(self).call(reason: NotificationReason::MENTIONED, format: :html)
expect(new_subject).to have_body_text(text)
new_subject = described_class.reassigned_merge_request_email(recipient.id, merge_request.id, [previous_assignee.id], current_user.id, nil)
- text = EmailsHelper.instance_method(:notification_reason_text).bind(self).call(nil)
+ text = EmailsHelper.instance_method(:notification_reason_text).bind(self).call(format: :html)
expect(new_subject).to have_body_text(text)
end
end
@@ -1550,7 +1551,7 @@ RSpec.describe Notify do
end
describe 'invitations' do
- let(:owner) { create(:user).tap { |u| group.add_user(u, Gitlab::Access::OWNER) } }
+ let(:owner) { create(:user).tap { |u| group.add_member(u, Gitlab::Access::OWNER) } }
let(:group_member) { invite_to_group(group, inviter: inviter) }
let(:inviter) { owner }
@@ -1605,7 +1606,7 @@ RSpec.describe Notify do
end
describe 'group invitation reminders' do
- let_it_be(:inviter) { create(:user).tap { |u| group.add_user(u, Gitlab::Access::OWNER) } }
+ let_it_be(:inviter) { create(:user).tap { |u| group.add_member(u, Gitlab::Access::OWNER) } }
let(:group_member) { invite_to_group(group, inviter: inviter) }
@@ -1688,7 +1689,7 @@ RSpec.describe Notify do
describe 'group invitation accepted' do
let(:invited_user) { create(:user, name: 'invited user') }
- let(:owner) { create(:user).tap { |u| group.add_user(u, Gitlab::Access::OWNER) } }
+ let(:owner) { create(:user).tap { |u| group.add_member(u, Gitlab::Access::OWNER) } }
let(:group_member) do
invitee = invite_to_group(group, inviter: owner)
invitee.accept_invite!(invited_user)
@@ -1714,7 +1715,7 @@ RSpec.describe Notify do
end
describe 'group invitation declined' do
- let(:owner) { create(:user).tap { |u| group.add_user(u, Gitlab::Access::OWNER) } }
+ let(:owner) { create(:user).tap { |u| group.add_member(u, Gitlab::Access::OWNER) } }
let(:group_member) do
invitee = invite_to_group(group, inviter: owner)
invitee.decline_invite!