Commit 7ce2f147 authored by Robert Speicher's avatar Robert Speicher

Merge branch '32156-fix-ci_usage_warning_message-message-builder' into 'master'

Fix `ci_usage_warning_message` message builder

See merge request gitlab-org/gitlab!16979
parents 9a5b73d9 771304fa
---
title: Prevent the user from seeing an invalid "Purchase more minutes" prompt.
merge_request: 16979
author:
type: fixed
......@@ -4,7 +4,7 @@ module EE
def ci_usage_warning_message(namespace, project)
message = [ci_usage_base_message(namespace)]
return unless message
return unless message.any?
if ::Gitlab.com? && can?(current_user, :admin_project, project)
message << purchase_shared_runner_minutes_link
......
......@@ -29,8 +29,8 @@ describe EE::RunnersHelper do
context 'when CI minutes quota is above the warning limits' do
let(:minutes_used) { 40 }
it 'does not return a message' do
expect(subject).to be_empty
it 'returns nil' do
expect(subject).to be_nil
end
end
......@@ -39,6 +39,16 @@ describe EE::RunnersHelper do
allow(helper).to receive(:can?).with(user, :admin_project, project) { true }
end
context 'when base message is not present' do
before do
allow(helper).to receive(:ci_usage_base_message).with(namespace).and_return(nil)
end
it 'returns nil' do
expect(subject).to be_nil
end
end
context 'when usage has reached first level of notification' do
before do
namespace.update_attribute(:last_ci_minutes_usage_notification_level, 50)
......@@ -61,6 +71,16 @@ describe EE::RunnersHelper do
end
context 'when current user is not an owner' do
context 'when base message is not present' do
before do
allow(helper).to receive(:ci_usage_base_message).with(namespace).and_return(nil)
end
it 'returns nil' do
expect(subject).to be_nil
end
end
context 'when usage has reached first level of notification' do
before do
namespace.update_attribute(:last_ci_minutes_usage_notification_level, 50)
......
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