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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /spec/mailers
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/mailers')
-rw-r--r--spec/mailers/devise_mailer_spec.rb30
-rw-r--r--spec/mailers/emails/merge_requests_spec.rb3
-rw-r--r--spec/mailers/emails/projects_spec.rb36
-rw-r--r--spec/mailers/emails/service_desk_spec.rb19
-rw-r--r--spec/mailers/notify_spec.rb197
5 files changed, 111 insertions, 174 deletions
diff --git a/spec/mailers/devise_mailer_spec.rb b/spec/mailers/devise_mailer_spec.rb
index 2ee15308400..c9dfee8255d 100644
--- a/spec/mailers/devise_mailer_spec.rb
+++ b/spec/mailers/devise_mailer_spec.rb
@@ -64,4 +64,34 @@ RSpec.describe DeviseMailer do
is_expected.to have_body_text /#{Gitlab.config.gitlab.url}/
end
end
+
+ describe '#user_admin_approval' do
+ subject { described_class.user_admin_approval(user) }
+
+ let_it_be(:user) { create(:user) }
+
+ it_behaves_like 'an email sent from GitLab'
+ it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like 'a user cannot unsubscribe through footer link'
+
+ 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 'Welcome to GitLab!'
+ end
+
+ it 'greets the user' do
+ is_expected.to have_body_text /Hi #{user.name}!/
+ end
+
+ it 'includes the correct content' do
+ is_expected.to have_body_text /Your GitLab account request has been approved!/
+ end
+
+ it 'includes a link to GitLab' do
+ is_expected.to have_link(Gitlab.config.gitlab.url)
+ end
+ end
end
diff --git a/spec/mailers/emails/merge_requests_spec.rb b/spec/mailers/emails/merge_requests_spec.rb
index 9235a946394..412cdff3aba 100644
--- a/spec/mailers/emails/merge_requests_spec.rb
+++ b/spec/mailers/emails/merge_requests_spec.rb
@@ -52,7 +52,8 @@ RSpec.describe Emails::MergeRequests do
it { expect(subject.subject).to eq("#{project.name} | Exported merge requests") }
it { expect(subject.to).to contain_exactly(user.notification_email_for(project.group)) }
- it { expect(subject).to have_content('Your CSV export of 10 merge requests from project')}
+ it { expect(subject.html_part).to have_content("Your CSV export of 10 merge requests from project") }
+ it { expect(subject.text_part).to have_content("Your CSV export of 10 merge requests from project") }
context 'when truncated' do
let(:export_status) do
diff --git a/spec/mailers/emails/projects_spec.rb b/spec/mailers/emails/projects_spec.rb
index aa5947bf68e..6c23625d4a3 100644
--- a/spec/mailers/emails/projects_spec.rb
+++ b/spec/mailers/emails/projects_spec.rb
@@ -32,19 +32,13 @@ RSpec.describe Emails::Projects do
describe '#prometheus_alert_fired_email' do
let(:default_title) { Gitlab::AlertManagement::Payload::Generic::DEFAULT_TITLE }
let(:payload) { { 'startsAt' => Time.now.rfc3339 } }
- let(:alert_attributes) { build(:alert_management_alert, :from_payload, payload: payload, project: project).attributes }
+ let(:alert) { create(:alert_management_alert, :from_payload, payload: payload, project: project) }
subject do
- Notify.prometheus_alert_fired_email(project.id, user.id, alert_attributes)
+ Notify.prometheus_alert_fired_email(project, user, alert)
end
- context 'missing required attributes' do
- let(:alert_attributes) { build(:alert_management_alert, :prometheus, :from_payload, payload: payload, project: project).attributes }
-
- it_behaves_like 'no email'
- end
-
- context 'with minimum required attributes' do
+ context 'with empty payload' do
let(:payload) { {} }
it_behaves_like 'an email sent from GitLab'
@@ -58,6 +52,7 @@ RSpec.describe Emails::Projects do
it 'has expected content' do
is_expected.to have_body_text('An alert has been triggered')
is_expected.to have_body_text(project.full_path)
+ is_expected.to have_body_text(alert.details_url)
is_expected.not_to have_body_text('Description:')
is_expected.not_to have_body_text('Environment:')
is_expected.not_to have_body_text('Metric:')
@@ -78,6 +73,7 @@ RSpec.describe Emails::Projects do
it 'has expected content' do
is_expected.to have_body_text('An alert has been triggered')
is_expected.to have_body_text(project.full_path)
+ is_expected.to have_body_text(alert.details_url)
is_expected.to have_body_text('Description:')
is_expected.to have_body_text('alert description')
is_expected.not_to have_body_text('Environment:')
@@ -101,6 +97,7 @@ RSpec.describe Emails::Projects do
it 'has expected content' do
is_expected.to have_body_text('An alert has been triggered')
is_expected.to have_body_text(project.full_path)
+ is_expected.to have_body_text(alert.details_url)
is_expected.to have_body_text('Environment:')
is_expected.to have_body_text(environment.name)
is_expected.not_to have_body_text('Description:')
@@ -112,7 +109,7 @@ RSpec.describe Emails::Projects do
let_it_be(:prometheus_alert) { create(:prometheus_alert, project: project) }
let_it_be(:environment) { prometheus_alert.environment }
- let(:alert_attributes) { build(:alert_management_alert, :prometheus, :from_payload, payload: payload, project: project).attributes }
+ let(:alert) { create(:alert_management_alert, :prometheus, :from_payload, payload: payload, project: project) }
let(:title) { "#{prometheus_alert.title} #{prometheus_alert.computed_operator} #{prometheus_alert.threshold}" }
let(:metrics_url) { metrics_project_environment_url(project, environment) }
@@ -135,6 +132,7 @@ RSpec.describe Emails::Projects do
it 'has expected content' do
is_expected.to have_body_text('An alert has been triggered')
is_expected.to have_body_text(project.full_path)
+ is_expected.to have_body_text(alert.details_url)
is_expected.to have_body_text('Environment:')
is_expected.to have_body_text(environment.name)
is_expected.to have_body_text('Metric:')
@@ -143,5 +141,23 @@ RSpec.describe Emails::Projects do
is_expected.not_to have_body_text('Description:')
end
end
+
+ context 'resolved' do
+ let_it_be(:alert) { create(:alert_management_alert, :resolved, project: project) }
+
+ it_behaves_like 'an email sent from GitLab'
+ it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like 'a user cannot unsubscribe through footer link'
+
+ it 'has expected subject' do
+ is_expected.to have_subject("#{project.name} | Alert: #{alert.title}")
+ end
+
+ it 'has expected content' do
+ is_expected.to have_body_text('An alert has been resolved')
+ is_expected.to have_body_text(project.full_path)
+ is_expected.to have_body_text(alert.details_url)
+ end
+ end
end
end
diff --git a/spec/mailers/emails/service_desk_spec.rb b/spec/mailers/emails/service_desk_spec.rb
index 842f82539cb..7d04b373be6 100644
--- a/spec/mailers/emails/service_desk_spec.rb
+++ b/spec/mailers/emails/service_desk_spec.rb
@@ -183,6 +183,25 @@ RSpec.describe Emails::ServiceDesk do
it_behaves_like 'handle template content', 'new_note'
end
+
+ context 'with upload link in the note' do
+ let_it_be(:upload_path) { '/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg' }
+ let_it_be(:note) { create(:note_on_issue, noteable: issue, project: project, note: "a new comment with [file](#{upload_path})") }
+
+ let(:template_content) { 'some text %{ NOTE_TEXT }' }
+ let(:expected_body) { %Q(some text a new comment with <a href="#{project.web_url}#{upload_path}" data-link="true" class="gfm">file</a>) }
+
+ it_behaves_like 'handle template content', 'new_note'
+ end
+
+ context 'with all-user reference in a an external author comment' do
+ let_it_be(:note) { create(:note_on_issue, noteable: issue, project: project, note: "Hey @all, just a ping", author: User.support_bot) }
+
+ let(:template_content) { 'some text %{ NOTE_TEXT }' }
+ let(:expected_body) { 'Hey , just a ping' }
+
+ it_behaves_like 'handle template content', 'new_note'
+ end
end
end
end
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 8604939ead9..3cc5f202b1f 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -619,6 +619,7 @@ RSpec.describe Notify do
let(:mailer) do
mailer = described_class.new
mailer.instance_variable_set(:@note, mail_thread_note)
+ mailer.instance_variable_set(:@target_url, "https://some.link")
mailer
end
@@ -887,96 +888,30 @@ RSpec.describe Notify do
subject { described_class.member_invited_email('project', project_member.id, project_member.invite_token) }
- context 'when invite_email_experiment is disabled' do
- before do
- stub_feature_flags(invite_email_experiment: false)
- end
-
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like 'an email sent from GitLab'
+ it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like 'appearance header and footer enabled'
+ it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like 'does not render a manage notifications link'
+ context 'when there is an inviter' do
it 'contains all the useful information' do
- is_expected.to have_subject "Invitation to join the #{project.full_name} project"
+ is_expected.to have_subject "#{inviter.name} invited you to join GitLab"
is_expected.to have_body_text project.full_name
- is_expected.to have_body_text project_member.human_access
+ is_expected.to have_body_text project_member.human_access.downcase
is_expected.to have_body_text project_member.invite_token
end
-
- context 'when member is invited via an email address' do
- it 'does add a param to the invite link' do
- is_expected.to have_body_text 'new_user_invite=control'
- end
-
- it 'tracks an event' do
- expect(Gitlab::Tracking).to receive(:event).with(
- 'Growth::Acquisition::Experiment::InviteEmail',
- 'sent',
- property: 'control_group'
- )
-
- subject.deliver_now
- end
- end
-
- context 'when member is already a user' do
- let(:project_member) { invite_to_project(project, inviter: maintainer, user: create(:user)) }
-
- it 'does not add a param to the invite link' do
- is_expected.not_to have_body_text 'new_user_invite'
- end
-
- it 'does not track an event' do
- expect(Gitlab::Tracking).not_to receive(:event)
-
- subject.deliver_now
- end
- end
end
- context 'when invite_email_experiment is enabled' do
- before do
- stub_feature_flags(invite_email_experiment: true)
- end
-
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like "a user cannot unsubscribe through footer link"
-
- context 'when there is no inviter' do
- let(:inviter) { nil }
-
- it 'contains all the useful information' do
- is_expected.to have_subject "Invitation to join the #{project.full_name} project"
- is_expected.to have_body_text project.full_name
- is_expected.to have_body_text project_member.human_access.downcase
- is_expected.to have_body_text project_member.invite_token
- end
- end
+ context 'when there is no inviter' do
+ let(:inviter) { nil }
- context 'when there is an inviter' do
- it 'contains all the useful information' do
- is_expected.to have_subject "#{inviter.name} invited you to join GitLab"
- is_expected.to have_body_text project.full_name
- is_expected.to have_body_text project_member.human_access.downcase
- is_expected.to have_body_text project_member.invite_token
- end
- end
-
- it 'adds a param to the invite link' do
- is_expected.to have_body_text 'new_user_invite=experiment'
- end
-
- it 'tracks an event' do
- expect(Gitlab::Tracking).to receive(:event).with(
- 'Growth::Acquisition::Experiment::InviteEmail',
- 'sent',
- property: 'experiment_group'
- )
-
- subject.deliver_now
+ it 'contains all the useful information' do
+ is_expected.to have_subject "Invitation to join the #{project.full_name} project"
+ is_expected.to have_body_text project.full_name
+ is_expected.to have_body_text project_member.human_access.downcase
+ is_expected.to have_body_text project_member.invite_token
end
end
end
@@ -1547,95 +1482,31 @@ RSpec.describe Notify do
end
end
- context 'when invite_email_experiment is disabled' do
- before do
- stub_feature_flags(invite_email_experiment: false)
- end
-
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
- it_behaves_like 'it requires a group'
+ it_behaves_like 'an email sent from GitLab'
+ it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like 'appearance header and footer enabled'
+ it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like 'it requires a group'
+ it_behaves_like 'does not render a manage notifications link'
+ context 'when there is an inviter' do
it 'contains all the useful information' do
- is_expected.to have_subject "Invitation to join the #{group.name} group"
+ is_expected.to have_subject "#{group_member.created_by.name} invited you to join GitLab"
is_expected.to have_body_text group.name
- is_expected.to have_body_text group.web_url
- is_expected.to have_body_text group_member.human_access
+ is_expected.to have_body_text group_member.human_access.downcase
is_expected.to have_body_text group_member.invite_token
end
-
- context 'when member is invited via an email address' do
- it 'does add a param to the invite link' do
- is_expected.to have_body_text 'new_user_invite=control'
- end
-
- it 'tracks an event' do
- expect(Gitlab::Tracking).to receive(:event).with(
- 'Growth::Acquisition::Experiment::InviteEmail',
- 'sent',
- property: 'control_group'
- )
-
- subject.deliver_now
- end
- end
-
- context 'when member is already a user' do
- let(:group_member) { invite_to_group(group, inviter: owner, user: create(:user)) }
-
- it 'does not add a param to the invite link' do
- is_expected.not_to have_body_text 'new_user_invite'
- end
-
- it 'does not track an event' do
- expect(Gitlab::Tracking).not_to receive(:event)
-
- subject.deliver_now
- end
- end
end
- context 'when invite_email_experiment is enabled' do
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'it requires a group'
-
- context 'when there is no inviter' do
- let(:inviter) { nil }
-
- it 'contains all the useful information' do
- is_expected.to have_subject "Invitation to join the #{group.name} group"
- is_expected.to have_body_text group.name
- is_expected.to have_body_text group_member.human_access.downcase
- is_expected.to have_body_text group_member.invite_token
- end
- end
+ context 'when there is no inviter' do
+ let(:inviter) { nil }
- context 'when there is an inviter' do
- it 'contains all the useful information' do
- is_expected.to have_subject "#{group_member.created_by.name} invited you to join GitLab"
- is_expected.to have_body_text group.name
- is_expected.to have_body_text group_member.human_access.downcase
- is_expected.to have_body_text group_member.invite_token
- end
- end
-
- it 'does add a param to the invite link' do
- is_expected.to have_body_text 'new_user_invite'
- end
-
- it 'tracks an event' do
- expect(Gitlab::Tracking).to receive(:event).with(
- 'Growth::Acquisition::Experiment::InviteEmail',
- 'sent',
- property: 'experiment_group'
- )
-
- subject.deliver_now
+ it 'contains all the useful information' do
+ is_expected.to have_subject "Invitation to join the #{group.name} group"
+ is_expected.to have_body_text group.name
+ is_expected.to have_body_text group_member.human_access.downcase
+ is_expected.to have_body_text group_member.invite_token
end
end
end