Commit 326fdcbf authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix spec failures

parent c1d5704f
......@@ -182,7 +182,7 @@ class Namespace < ActiveRecord::Base
end
def shared_runners_enabled?
projects.where(shared_runners_enabled: true).any?
projects.with_shared_runners.any?
end
def full_name
......
......@@ -13,7 +13,7 @@ module EE
# select projects which have allowed number of shared runner minutes or are public
super.
where("projects.visibility_level=? OR (#{builds_check_limit.to_sql})=1",
Gitlab::VisibilityLevel::PUBLIC)
::Gitlab::VisibilityLevel::PUBLIC)
end
def builds_check_limit
......
......@@ -8,7 +8,7 @@ class UpdateBuildMinutesService < BaseService
shared_runners_minutes: build.duration)
NamespaceStatistics.update_counters(namespace_statistics,
shared_runners_minutes: build.duration)
shared_runners_minutes: build.duration)
end
private
......
......@@ -39,7 +39,7 @@
= project.shared_runners_minutes
- if @projects.blank?
%tr
%td{colspan: 2}
%td{ colspan: 2 }
.nothing-here-block This group has no projects which use shared runners
= paginate @projects, theme: "gitlab"
......@@ -4,7 +4,7 @@
- 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
.shared-runner-quota-message.alert.alert-warning.hidden-xs{ data: { scope: scope }}
.shared-runner-quota-message.alert.alert-warning.hidden-xs{ data: { scope: scope } }
= namespace.name
has exceeded their build minutes quota. Pipelines will not run anymore on shared runners.
......
......@@ -81,13 +81,19 @@ describe Group, models: true do
describe 'public_only' do
subject { described_class.public_only.to_a }
it{ is_expected.to eq([group]) }
it { is_expected.to eq([group]) }
end
describe 'public_and_internal_only' do
subject { described_class.public_and_internal_only.to_a }
it{ is_expected.to match_array([group, internal_group]) }
it { is_expected.to match_array([group, internal_group]) }
end
describe 'non_public_only' do
subject { described_class.non_public_only.to_a }
it { is_expected.to match_array([private_group, internal_group]) }
end
end
......
......@@ -976,6 +976,26 @@ describe Project, models: true do
it { expect(project.builds_enabled?).to be_truthy }
end
describe '.with_shared_runners' do
subject { Project.with_shared_runners }
context 'when shared runners are enabled for project' do
let!(:project) { create(:empty_project, shared_runners_enabled: true) }
it "returns a project" do
is_expected.to eq([project])
end
end
context 'when shared runners are disabled for project' do
let!(:project) { create(:empty_project, shared_runners_enabled: false) }
it "returns a project" do
is_expected.to eq([project])
end
end
end
describe '.cached_count', caching: true do
let(:group) { create(:group, :public) }
let!(:project1) { create(:empty_project, :public, group: group) }
......@@ -1118,6 +1138,28 @@ describe Project, models: true do
end
end
describe '#shared_runners' do
let!(:runner) { create(:ci_runner, :shared) }
subject { project.shared_runners }
context 'when shared runners are enabled for project' do
let!(:project) { create(:empty_project, shared_runners_enabled: true) }
it "returns a list of shared runners" do
is_expected.to eq([runner])
end
end
context 'when shared runners are disabled for project' do
let!(:project) { create(:empty_project, shared_runners_enabled: false) }
it "returns a empty list" do
is_expected.to be_nil
end
end
end
describe '#visibility_level_allowed?' do
let(:project) { create(:project, :internal) }
......
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