Commit d159135a authored by Robert Speicher's avatar Robert Speicher

Merge branch 'dm-mirror-hard-failed-invites-ee' into 'master'

Prevent hard-failing a mirror or sending an access request from failing when the project has invited masters/owners

See merge request gitlab-org/gitlab-ee!4975
parents 92e8d937 e98b67d5
......@@ -56,7 +56,7 @@ class Member < ActiveRecord::Base
scope :active_without_invites, -> do
left_join_users
.where(users: { state: 'active' })
.where(requested_at: nil)
.non_request
.reorder(nil)
end
......
......@@ -231,9 +231,9 @@ class NotificationService
def new_access_request(member)
return true unless member.notifiable?(:subscription)
recipients = member.source.members.owners_and_masters
recipients = member.source.members.active_without_invites.owners_and_masters
if fallback_to_group_owners_masters?(recipients, member)
recipients = member.source.group.members.owners_and_masters
recipients = member.source.group.members.active_without_invites.owners_and_masters
end
recipients.each { |recipient| deliver_access_request_email(recipient, member) }
......
......@@ -24,10 +24,10 @@ module EE
end
def mirror_was_hard_failed(project)
recipients = project.members.owners_and_masters
recipients = project.members.active_without_invites.owners_and_masters
unless recipients.present?
recipients = project.group.members.owners_and_masters
recipients = project.group.members.active_without_invites.owners_and_masters
end
recipients.each do |recipient|
......
......@@ -123,6 +123,17 @@ describe EE::NotificationService, :mailer do
describe 'mirror hard failed' do
let(:user) { create(:user) }
context 'when the project has invited members' do
it 'sends email' do
project = create(:project, :mirror, :import_hard_failed)
create(:project_member, :invited, project: project)
expect(Notify).to receive(:mirror_was_hard_failed_email).with(project.id, project.owner.id).and_call_original
subject.mirror_was_hard_failed(project)
end
end
context 'when user is owner' do
it 'sends email' do
project = create(:project, :mirror, :import_hard_failed)
......
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