Commit a6948538 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Improve specs

parent 71ef0c9e
......@@ -538,7 +538,7 @@ module Ci
end
def shared_runners_minutes_quota?
runner && runner.shared? && !project.public?
runner && runner.shared? && project.shared_runners_minutes_quota?
end
private
......
......@@ -1567,6 +1567,10 @@ class Project < ActiveRecord::Base
end
end
def shared_runners_minutes_quota?
!public? && shared_runners_enabled?
end
private
# Check if a reference is being done cross-project
......
- project = local_assigns.fetch(:project, nil)
- namespace = local_assigns.fetch(:namespace, project && project.namespace)
- has_limit = (project || namespace).shared_runners_minutes_limit_enabled?
- can_see_status = project.nil? || can?(current_user, :create_pipeline, project)
- if cookies[:hide_shared_runner_quota_message].blank? && has_limit && namespace.shared_runners_minutes_used? && can_see_status
- if cookies[:hide_shared_runner_quota_message].blank? &&
project.shared_runners_minutes_quota? &&
namespace.shared_runners_minutes_used? &&
can?(current_user, :create_pipeline, project)
.shared-runner-quota-message.alert.alert-warning.hidden-xs
= namespace.name
has exceeded their build minutes quota. Pipelines will not run anymore on shared runners.
......
......@@ -1330,28 +1330,11 @@ describe Ci::Build, models: true do
build.runner = create(:ci_runner, :shared)
end
context 'for public project' do
before do
build.project.visibility_level = Gitlab::VisibilityLevel::PUBLIC
end
it { is_expected.to be_falsey }
end
context 'for internal project' do
before do
build.project.visibility_level = Gitlab::VisibilityLevel::INTERNAL
end
it do
expect(build.project).to receive(:shared_runners_minutes_quota?).
and_return(true)
it { is_expected.to be_truthy }
end
context 'for private project' do
before do
build.project.visibility_level = Gitlab::VisibilityLevel::INTERNAL
end
it { is_expected.to be_truthy }
is_expected.to be_truthy
end
end
......
......@@ -2092,6 +2092,48 @@ describe Project, models: true do
end
end
describe '#shared_runners_minutes_quota?' do
subject { project.shared_runners_minutes_quota? }
context 'with shared runners enabled' do
before do
project.shared_runners_enabled = true
end
context 'for public project' do
before do
project.visibility_level = Project::PUBLIC
end
it { is_expected.to be_falsey }
end
context 'for internal project' do
before do
project.visibility_level = Project::INTERNAL
end
it { is_expected.to be_truthy }
end
context 'for private project' do
before do
project.visibility_level = Project::INTERNAL
end
it { is_expected.to be_truthy }
end
end
context 'without shared runners' do
before do
project.shared_runners_enabled = false
end
it { is_expected.to be_falsey }
end
end
def enable_lfs
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
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