Commit 03fd1f30 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents c374d877 833cb6e9
...@@ -17,13 +17,9 @@ ...@@ -17,13 +17,9 @@
import defaultAvatarUrl from 'images/no_avatar.png'; import defaultAvatarUrl from 'images/no_avatar.png';
import { placeholderImage } from '../../../lazy_loader'; import { placeholderImage } from '../../../lazy_loader';
import tooltip from '../../directives/tooltip';
export default { export default {
name: 'ProjectAvatarImage', name: 'ProjectAvatarImage',
directives: {
tooltip,
},
props: { props: {
lazy: { lazy: {
type: Boolean, type: Boolean,
...@@ -50,16 +46,6 @@ export default { ...@@ -50,16 +46,6 @@ export default {
required: false, required: false,
default: 20, default: 20,
}, },
tooltipText: {
type: String,
required: false,
default: '',
},
tooltipPlacement: {
type: String,
required: false,
default: 'top',
},
}, },
computed: { computed: {
// API response sends null when gravatar is disabled and // API response sends null when gravatar is disabled and
...@@ -71,9 +57,6 @@ export default { ...@@ -71,9 +57,6 @@ export default {
resultantSrcAttribute() { resultantSrcAttribute() {
return this.lazy ? placeholderImage : this.sanitizedSource; return this.lazy ? placeholderImage : this.sanitizedSource;
}, },
tooltipContainer() {
return this.tooltipText ? 'body' : null;
},
avatarSizeClass() { avatarSizeClass() {
return `s${this.size}`; return `s${this.size}`;
}, },
...@@ -83,7 +66,6 @@ export default { ...@@ -83,7 +66,6 @@ export default {
<template> <template>
<img <img
v-tooltip
:class="{ :class="{
lazy: lazy, lazy: lazy,
[avatarSizeClass]: true, [avatarSizeClass]: true,
...@@ -94,9 +76,6 @@ export default { ...@@ -94,9 +76,6 @@ export default {
:height="size" :height="size"
:alt="imgAlt" :alt="imgAlt"
:data-src="sanitizedSource" :data-src="sanitizedSource"
:data-container="tooltipContainer"
:data-placement="tooltipPlacement"
:title="tooltipText"
class="avatar" class="avatar"
/> />
</template> </template>
...@@ -60,7 +60,7 @@ module Emails ...@@ -60,7 +60,7 @@ module Emails
# `note_id` is a `Note` when originating in `NotifyPreview` # `note_id` is a `Note` when originating in `NotifyPreview`
@note = note_id.is_a?(Note) ? note_id : Note.find(note_id) @note = note_id.is_a?(Note) ? note_id : Note.find(note_id)
@project = @note.project @project = @note.project
@group = @note.noteable.try(:group) @group = @project.try(:group) || @note.noteable.try(:group)
if (@project || @group) && @note.persisted? if (@project || @group) && @note.persisted?
@sent_notification = SentNotification.record_note(@note, recipient_id, reply_key) @sent_notification = SentNotification.record_note(@note, recipient_id, reply_key)
......
...@@ -9,7 +9,6 @@ class BuildSuccessWorker ...@@ -9,7 +9,6 @@ class BuildSuccessWorker
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id) def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build| Ci::Build.find_by(id: build_id).try do |build|
create_deployment(build) if build.has_environment?
stop_environment(build) if build.stops_environment? stop_environment(build) if build.stops_environment?
end end
end end
...@@ -17,17 +16,6 @@ class BuildSuccessWorker ...@@ -17,17 +16,6 @@ class BuildSuccessWorker
private private
##
# Deprecated:
# As of 11.5, we started creating a deployment record when ci_builds record is created.
# Therefore we no longer need to create a deployment, after a build succeeded.
# We're leaving this code for the transition period, but we can remove this code in 11.6.
def create_deployment(build)
build.create_deployment.try do |deployment|
deployment.succeed
end
end
## ##
# TODO: This should be processed in DeploymentSuccessWorker once we started storing `action` value in `deployments` records # TODO: This should be processed in DeploymentSuccessWorker once we started storing `action` value in `deployments` records
def stop_environment(build) def stop_environment(build)
......
---
title: Fix comment emails not respecting group-level notification email
merge_request:
author:
type: fixed
---
title: Remove tooltip directive on project avatar image component
merge_request: 29631
author: George Tsiolis
type: performance
...@@ -9,7 +9,7 @@ describe Emails::PagesDomains do ...@@ -9,7 +9,7 @@ describe Emails::PagesDomains do
set(:user) { project.creator } set(:user) { project.creator }
shared_examples 'a pages domain email' do shared_examples 'a pages domain email' do
let(:test_recipient) { user } let(:recipient) { user }
it_behaves_like 'an email sent to a user' it_behaves_like 'an email sent to a user'
it_behaves_like 'an email sent from GitLab' it_behaves_like 'an email sent from GitLab'
......
...@@ -45,7 +45,7 @@ describe Notify do ...@@ -45,7 +45,7 @@ describe Notify do
context 'for a project' do context 'for a project' do
shared_examples 'an assignee email' do shared_examples 'an assignee email' do
let(:test_recipient) { assignee } let(:recipient) { assignee }
it_behaves_like 'an email sent to a user' it_behaves_like 'an email sent to a user'
...@@ -55,7 +55,7 @@ describe Notify do ...@@ -55,7 +55,7 @@ describe Notify do
aggregate_failures do aggregate_failures do
expect(sender.display_name).to eq(current_user.name) expect(sender.display_name).to eq(current_user.name)
expect(sender.address).to eq(gitlab_sender) expect(sender.address).to eq(gitlab_sender)
expect(subject).to deliver_to(assignee.email) expect(subject).to deliver_to(recipient.notification_email)
end end
end end
end end
...@@ -547,12 +547,13 @@ describe Notify do ...@@ -547,12 +547,13 @@ describe Notify do
let(:host) { Gitlab.config.gitlab.host } let(:host) { Gitlab.config.gitlab.host }
context 'in discussion' do context 'in discussion' do
set(:first_note) { create(:discussion_note_on_issue) } set(:first_note) { create(:discussion_note_on_issue, project: project) }
set(:second_note) { create(:discussion_note_on_issue, in_reply_to: first_note) } set(:second_note) { create(:discussion_note_on_issue, in_reply_to: first_note, project: project) }
set(:third_note) { create(:discussion_note_on_issue, in_reply_to: second_note) } set(:third_note) { create(:discussion_note_on_issue, in_reply_to: second_note, project: project) }
subject { described_class.note_issue_email(recipient.id, third_note.id) } subject { described_class.note_issue_email(recipient.id, third_note.id) }
it_behaves_like 'an email sent to a user'
it_behaves_like 'appearance header and footer enabled' it_behaves_like 'appearance header and footer enabled'
it_behaves_like 'appearance header and footer not enabled' it_behaves_like 'appearance header and footer not enabled'
...@@ -572,10 +573,11 @@ describe Notify do ...@@ -572,10 +573,11 @@ describe Notify do
end end
context 'individual issue comments' do context 'individual issue comments' do
set(:note) { create(:note_on_issue) } set(:note) { create(:note_on_issue, project: project) }
subject { described_class.note_issue_email(recipient.id, note.id) } subject { described_class.note_issue_email(recipient.id, note.id) }
it_behaves_like 'an email sent to a user'
it_behaves_like 'appearance header and footer enabled' it_behaves_like 'appearance header and footer enabled'
it_behaves_like 'appearance header and footer not enabled' it_behaves_like 'appearance header and footer not enabled'
...@@ -604,13 +606,13 @@ describe Notify do ...@@ -604,13 +606,13 @@ describe Notify do
it_behaves_like 'a user cannot unsubscribe through footer link' it_behaves_like 'a user cannot unsubscribe through footer link'
it 'has the correct subject and body' do it 'has the correct subject and body' do
is_expected.to have_referable_subject(project_snippet, reply: true) is_expected.to have_referable_subject(project_snippet, include_group: true, reply: true)
is_expected.to have_body_text project_snippet_note.note is_expected.to have_body_text project_snippet_note.note
end end
end end
describe 'project was moved' do describe 'project was moved' do
let(:test_recipient) { user } let(:recipient) { user }
subject { described_class.project_was_moved_email(project.id, user.id, "gitlab/gitlab") } subject { described_class.project_was_moved_email(project.id, user.id, "gitlab/gitlab") }
it_behaves_like 'an email sent to a user' it_behaves_like 'an email sent to a user'
...@@ -811,7 +813,7 @@ describe Notify do ...@@ -811,7 +813,7 @@ describe Notify do
it 'has the correct subject and body' do it 'has the correct subject and body' do
aggregate_failures do aggregate_failures do
is_expected.to have_subject("Re: #{project.name} | #{commit.title} (#{commit.short_id})") is_expected.to have_subject("Re: #{project.name} | #{project.group.name} | #{commit.title} (#{commit.short_id})")
is_expected.to have_body_text(commit.short_id) is_expected.to have_body_text(commit.short_id)
end end
end end
...@@ -837,7 +839,7 @@ describe Notify do ...@@ -837,7 +839,7 @@ describe Notify do
it 'has the correct subject and body' do it 'has the correct subject and body' do
aggregate_failures do aggregate_failures do
is_expected.to have_referable_subject(merge_request, reply: true) is_expected.to have_referable_subject(merge_request, include_group: true, reply: true)
is_expected.to have_body_text note_on_merge_request_path is_expected.to have_body_text note_on_merge_request_path
end end
end end
...@@ -863,7 +865,7 @@ describe Notify do ...@@ -863,7 +865,7 @@ describe Notify do
it 'has the correct subject and body' do it 'has the correct subject and body' do
aggregate_failures do aggregate_failures do
is_expected.to have_referable_subject(issue, reply: true) is_expected.to have_referable_subject(issue, include_group: true, reply: true)
is_expected.to have_body_text(note_on_issue_path) is_expected.to have_body_text(note_on_issue_path)
end end
end end
...@@ -929,7 +931,7 @@ describe Notify do ...@@ -929,7 +931,7 @@ describe Notify do
it_behaves_like 'appearance header and footer not enabled' it_behaves_like 'appearance header and footer not enabled'
it 'has the correct subject' do it 'has the correct subject' do
is_expected.to have_subject "Re: #{project.name} | #{commit.title} (#{commit.short_id})" is_expected.to have_subject "Re: #{project.name} | #{project.group.name} | #{commit.title} (#{commit.short_id})"
end end
it 'contains a link to the commit' do it 'contains a link to the commit' do
...@@ -957,7 +959,7 @@ describe Notify do ...@@ -957,7 +959,7 @@ describe Notify do
it_behaves_like 'appearance header and footer not enabled' it_behaves_like 'appearance header and footer not enabled'
it 'has the correct subject' do it 'has the correct subject' do
is_expected.to have_referable_subject(merge_request, reply: true) is_expected.to have_referable_subject(merge_request, include_group: true, reply: true)
end end
it 'contains a link to the merge request note' do it 'contains a link to the merge request note' do
...@@ -985,7 +987,7 @@ describe Notify do ...@@ -985,7 +987,7 @@ describe Notify do
it_behaves_like 'appearance header and footer not enabled' it_behaves_like 'appearance header and footer not enabled'
it 'has the correct subject' do it 'has the correct subject' do
is_expected.to have_referable_subject(issue, reply: true) is_expected.to have_referable_subject(issue, include_group: true, reply: true)
end end
it 'contains a link to the issue note' do it 'contains a link to the issue note' do
......
...@@ -37,8 +37,19 @@ module EmailHelpers ...@@ -37,8 +37,19 @@ module EmailHelpers
ActionMailer::Base.deliveries.find { |d| d.to.include?(user.notification_email) } ActionMailer::Base.deliveries.find { |d| d.to.include?(user.notification_email) }
end end
def have_referable_subject(referable, include_project: true, reply: false) def have_referable_subject(referable, include_project: true, include_group: false, reply: false)
prefix = (include_project && referable.project ? "#{referable.project.name} | " : '').freeze context = []
context << referable.project.name if include_project && referable.project
context << referable.project.group.name if include_group && referable.project.group
prefix =
if context.any?
context.join(' | ') + ' | '
else
''
end
prefix = "Re: #{prefix}" if reply prefix = "Re: #{prefix}" if reply
suffix = "#{referable.title} (#{referable.to_reference})" suffix = "#{referable.title} (#{referable.to_reference})"
......
...@@ -45,18 +45,18 @@ shared_examples 'an email sent to a user' do ...@@ -45,18 +45,18 @@ shared_examples 'an email sent to a user' do
let(:group_notification_email) { 'user+group@example.com' } let(:group_notification_email) { 'user+group@example.com' }
it 'is sent to user\'s global notification email address' do it 'is sent to user\'s global notification email address' do
expect(subject).to deliver_to(test_recipient.notification_email) expect(subject).to deliver_to(recipient.notification_email)
end end
context 'that is part of a project\'s group' do context 'that is part of a project\'s group' do
it 'is sent to user\'s group notification email address when set' do it 'is sent to user\'s group notification email address when set' do
create(:notification_setting, user: test_recipient, source: project.group, notification_email: group_notification_email) create(:notification_setting, user: recipient, source: project.group, notification_email: group_notification_email)
expect(subject).to deliver_to(group_notification_email) expect(subject).to deliver_to(group_notification_email)
end end
it 'is sent to user\'s global notification email address when no group email set' do it 'is sent to user\'s global notification email address when no group email set' do
create(:notification_setting, user: test_recipient, source: project.group, notification_email: '') create(:notification_setting, user: recipient, source: project.group, notification_email: '')
expect(subject).to deliver_to(test_recipient.notification_email) expect(subject).to deliver_to(recipient.notification_email)
end end
end end
...@@ -67,17 +67,17 @@ shared_examples 'an email sent to a user' do ...@@ -67,17 +67,17 @@ shared_examples 'an email sent to a user' do
it 'is sent to user\'s subgroup notification email address when set' do it 'is sent to user\'s subgroup notification email address when set' do
# Set top-level group notification email address to make sure it doesn't get selected # Set top-level group notification email address to make sure it doesn't get selected
create(:notification_setting, user: test_recipient, source: group, notification_email: group_notification_email) create(:notification_setting, user: recipient, source: group, notification_email: group_notification_email)
subgroup_notification_email = 'user+subgroup@example.com' subgroup_notification_email = 'user+subgroup@example.com'
create(:notification_setting, user: test_recipient, source: subgroup, notification_email: subgroup_notification_email) create(:notification_setting, user: recipient, source: subgroup, notification_email: subgroup_notification_email)
expect(subject).to deliver_to(subgroup_notification_email) expect(subject).to deliver_to(subgroup_notification_email)
end end
it 'is sent to user\'s group notification email address when set and subgroup email address not set' do it 'is sent to user\'s group notification email address when set and subgroup email address not set' do
create(:notification_setting, user: test_recipient, source: subgroup, notification_email: '') create(:notification_setting, user: recipient, source: subgroup, notification_email: '')
expect(subject).to deliver_to(test_recipient.notification_email) expect(subject).to deliver_to(recipient.notification_email)
end end
end end
end end
......
...@@ -6,51 +6,7 @@ describe BuildSuccessWorker do ...@@ -6,51 +6,7 @@ describe BuildSuccessWorker do
describe '#perform' do describe '#perform' do
subject { described_class.new.perform(build.id) } subject { described_class.new.perform(build.id) }
before do
allow_any_instance_of(Deployment).to receive(:create_ref)
end
context 'when build exists' do context 'when build exists' do
context 'when deployment was not created with the build creation' do # An edge case during the transition period
let!(:build) { create(:ci_build, :deploy_to_production) }
before do
allow(Deployments::FinishedWorker).to receive(:perform_async)
Deployment.delete_all
build.reload
end
it 'creates a successful deployment' do
expect(build).not_to be_has_deployment
subject
build.reload
expect(build).to be_has_deployment
expect(build.deployment).to be_success
end
end
context 'when deployment was created with the build creation' do # Counter part of the above edge case
let!(:build) { create(:ci_build, :deploy_to_production) }
it 'does not create a new deployment' do
expect(build).to be_has_deployment
expect { subject }.not_to change { Deployment.count }
end
end
context 'when build is not associated with project' do
let!(:build) { create(:ci_build, project: nil) }
it 'does not create deployment' do
subject
expect(build.reload).not_to be_has_deployment
end
end
context 'when the build will stop an environment' do context 'when the build will stop an environment' do
let!(:build) { create(:ci_build, :stop_review_app, environment: environment.name, project: environment.project) } let!(:build) { create(:ci_build, :stop_review_app, environment: environment.name, project: environment.project) }
let(:environment) { create(:environment, state: :available) } let(:environment) { create(:environment, state: :available) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment