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

Fix spec failures

parent c1d5704f
...@@ -182,7 +182,7 @@ class Namespace < ActiveRecord::Base ...@@ -182,7 +182,7 @@ class Namespace < ActiveRecord::Base
end end
def shared_runners_enabled? def shared_runners_enabled?
projects.where(shared_runners_enabled: true).any? projects.with_shared_runners.any?
end end
def full_name def full_name
......
...@@ -13,7 +13,7 @@ module EE ...@@ -13,7 +13,7 @@ module EE
# select projects which have allowed number of shared runner minutes or are public # select projects which have allowed number of shared runner minutes or are public
super. super.
where("projects.visibility_level=? OR (#{builds_check_limit.to_sql})=1", where("projects.visibility_level=? OR (#{builds_check_limit.to_sql})=1",
Gitlab::VisibilityLevel::PUBLIC) ::Gitlab::VisibilityLevel::PUBLIC)
end end
def builds_check_limit def builds_check_limit
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
= project.shared_runners_minutes = project.shared_runners_minutes
- if @projects.blank? - if @projects.blank?
%tr %tr
%td{colspan: 2} %td{ colspan: 2 }
.nothing-here-block This group has no projects which use shared runners .nothing-here-block This group has no projects which use shared runners
= paginate @projects, theme: "gitlab" = paginate @projects, theme: "gitlab"
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
- has_limit = (project || namespace).shared_runners_minutes_limit_enabled? - has_limit = (project || namespace).shared_runners_minutes_limit_enabled?
- can_see_status = project.nil? || can?(current_user, :create_pipeline, project) - 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? && 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 = namespace.name
has exceeded their build minutes quota. Pipelines will not run anymore on shared runners. has exceeded their build minutes quota. Pipelines will not run anymore on shared runners.
......
...@@ -81,13 +81,19 @@ describe Group, models: true do ...@@ -81,13 +81,19 @@ describe Group, models: true do
describe 'public_only' do describe 'public_only' do
subject { described_class.public_only.to_a } subject { described_class.public_only.to_a }
it{ is_expected.to eq([group]) } it { is_expected.to eq([group]) }
end end
describe 'public_and_internal_only' do describe 'public_and_internal_only' do
subject { described_class.public_and_internal_only.to_a } 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
end end
......
...@@ -976,6 +976,26 @@ describe Project, models: true do ...@@ -976,6 +976,26 @@ describe Project, models: true do
it { expect(project.builds_enabled?).to be_truthy } it { expect(project.builds_enabled?).to be_truthy }
end 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 describe '.cached_count', caching: true do
let(:group) { create(:group, :public) } let(:group) { create(:group, :public) }
let!(:project1) { create(:empty_project, :public, group: group) } let!(:project1) { create(:empty_project, :public, group: group) }
...@@ -1118,6 +1138,28 @@ describe Project, models: true do ...@@ -1118,6 +1138,28 @@ describe Project, models: true do
end end
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 describe '#visibility_level_allowed?' do
let(:project) { create(:project, :internal) } 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