Commit 474e5368 authored by Rubén Dávila's avatar Rubén Dávila

Don't send CI usage email notifications for self-hosted instances

Notifications should be only sent for GL.com customers.
parent fce7307f
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
class CiMinutesUsageNotifyService < BaseService class CiMinutesUsageNotifyService < BaseService
def execute def execute
return unless ::Gitlab.com?
notify_on_total_usage notify_on_total_usage
notify_on_partial_usage notify_on_partial_usage
end end
......
---
title: Don't send CI usage email notifications for self-hosted instances
merge_request: 14809
author:
type: fixed
...@@ -32,6 +32,12 @@ describe CiMinutesUsageNotifyService do ...@@ -32,6 +32,12 @@ describe CiMinutesUsageNotifyService do
create(:namespace_statistics, namespace: namespace, shared_runners_seconds: ci_minutes_used * 60) create(:namespace_statistics, namespace: namespace, shared_runners_seconds: ci_minutes_used * 60)
end end
let(:gitlab_dot_com) { true }
before do
allow(Gitlab).to receive(:com?).and_return(gitlab_dot_com)
end
describe '#execute' do describe '#execute' do
let(:extra_ci_minutes) { 0 } let(:extra_ci_minutes) { 0 }
let(:namespace) do let(:namespace) do
...@@ -40,6 +46,17 @@ describe CiMinutesUsageNotifyService do ...@@ -40,6 +46,17 @@ describe CiMinutesUsageNotifyService do
subject { described_class.new(project).execute } subject { described_class.new(project).execute }
context 'when it is not GitLab.com' do
let(:gitlab_dot_com) { false }
let(:ci_minutes_used) { 2500 }
it 'does not send the email to all the owners' do
expect(CiMinutesUsageMailer).not_to receive(:notify)
subject
end
end
context 'with a personal namespace' do context 'with a personal namespace' do
before do before do
namespace.update(owner_id: user.id) namespace.update(owner_id: user.id)
...@@ -165,6 +182,13 @@ describe CiMinutesUsageNotifyService do ...@@ -165,6 +182,13 @@ describe CiMinutesUsageNotifyService do
end end
context 'when available minutes have reached the first level of alert' do context 'when available minutes have reached the first level of alert' do
context 'when it is not GitLab.com' do
let(:gitlab_dot_com) { false }
let(:ci_minutes_used) { 1500 }
it_behaves_like 'no notification is sent'
end
it_behaves_like 'notification for custom level is sent', 1500, 30 it_behaves_like 'notification for custom level is sent', 1500, 30
context 'when other Pipeline has finished but second level of alert has not been reached' do context 'when other Pipeline has finished but second level of alert has not been reached' do
......
...@@ -22,6 +22,7 @@ describe BuildFinishedWorker do ...@@ -22,6 +22,7 @@ describe BuildFinishedWorker do
describe '#perform' do describe '#perform' do
before do before do
allow(Gitlab).to receive(:com?).and_return(true)
allow_any_instance_of(EE::Project).to receive(:shared_runners_minutes_limit_enabled?).and_return(true) allow_any_instance_of(EE::Project).to receive(:shared_runners_minutes_limit_enabled?).and_return(true)
end end
......
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