Commit d460490c authored by Douwe Maan's avatar Douwe Maan

Merge branch...

Merge branch '5358-hard-failing-mirror-fails-for-personal-project-with-blocked-owners' into 'master'

Resolve "Hard-failing a mirror fails for personal projects with blocked owners"

Closes #5358

See merge request gitlab-org/gitlab-ee!5063
parents 9e9748e6 37afc065
...@@ -268,13 +268,13 @@ class Group < Namespace ...@@ -268,13 +268,13 @@ class Group < Namespace
end end
GroupMember GroupMember
.active_without_invites .active_without_invites_and_requests
.where(source_id: source_ids) .where(source_id: source_ids)
end end
def members_with_descendants def members_with_descendants
GroupMember GroupMember
.active_without_invites .active_without_invites_and_requests
.where(source_id: self_and_descendants.reorder(nil).select(:id)) .where(source_id: self_and_descendants.reorder(nil).select(:id))
end end
......
...@@ -53,7 +53,7 @@ class Member < ActiveRecord::Base ...@@ -53,7 +53,7 @@ class Member < ActiveRecord::Base
end end
# Like active, but without invites. For when a User is required. # Like active, but without invites. For when a User is required.
scope :active_without_invites, -> do scope :active_without_invites_and_requests, -> do
left_join_users left_join_users
.where(users: { state: 'active' }) .where(users: { state: 'active' })
.non_request .non_request
......
...@@ -231,9 +231,9 @@ class NotificationService ...@@ -231,9 +231,9 @@ class NotificationService
def new_access_request(member) def new_access_request(member)
return true unless member.notifiable?(:subscription) return true unless member.notifiable?(:subscription)
recipients = member.source.members.active_without_invites.owners_and_masters recipients = member.source.members.active_without_invites_and_requests.owners_and_masters
if fallback_to_group_owners_masters?(recipients, member) if fallback_to_group_owners_masters?(recipients, member)
recipients = member.source.group.members.active_without_invites.owners_and_masters recipients = member.source.group.members.active_without_invites_and_requests.owners_and_masters
end end
recipients.each { |recipient| deliver_access_request_email(recipient, member) } recipients.each { |recipient| deliver_access_request_email(recipient, member) }
......
...@@ -24,10 +24,10 @@ module EE ...@@ -24,10 +24,10 @@ module EE
end end
def mirror_was_hard_failed(project) def mirror_was_hard_failed(project)
recipients = project.members.active_without_invites.owners_and_masters recipients = project.members.active_without_invites_and_requests.owners_and_masters
unless recipients.present? if recipients.empty? && project.group
recipients = project.group.members.active_without_invites.owners_and_masters recipients = project.group.members.active_without_invites_and_requests.owners_and_masters
end end
recipients.each do |recipient| recipients.each do |recipient|
......
---
title: Hard failing a mirror no longer fails for a blocked user's personal project
merge_request: 5063
author:
type: fixed
...@@ -142,6 +142,34 @@ describe EE::NotificationService, :mailer do ...@@ -142,6 +142,34 @@ describe EE::NotificationService, :mailer do
subject.mirror_was_hard_failed(project) subject.mirror_was_hard_failed(project)
end end
context 'when owner is blocked' do
it 'does not send email' do
project = create(:project, :mirror, :import_hard_failed)
project.owner.block!
expect(Notify).not_to receive(:mirror_was_hard_failed_email)
subject.mirror_was_hard_failed(project)
end
context 'when project belongs to group' do
it 'does not send email to the blocked owner' do
blocked_user = create(:user, :blocked)
group = create(:group, :public)
group.add_owner(blocked_user)
group.add_owner(user)
project = create(:project, :mirror, :import_hard_failed, namespace: group)
expect(Notify).not_to receive(:mirror_was_hard_failed_email).with(project.id, blocked_user.id).and_call_original
expect(Notify).to receive(:mirror_was_hard_failed_email).with(project.id, user.id).and_call_original
subject.mirror_was_hard_failed(project)
end
end
end
end end
context 'when user is master' do context 'when user is master' do
......
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