Commit 35b94edd authored by Kamil Trzcinski's avatar Kamil Trzcinski

Merge branch 'introduce-build-minutes' of gitlab.com:gitlab-org/gitlab-ee into...

Merge branch 'introduce-build-minutes' of gitlab.com:gitlab-org/gitlab-ee into introduce-build-minutes
parents 3e147204 5b97b793
class UpdateBuildMinutesService
class UpdateBuildMinutesService < BaseService
def execute(build)
return unless build.runner.try(:shared?)
return unless build.project.try(:shared_runners_minutes_limit_enabled?)
......
......@@ -220,7 +220,7 @@
.col-sm-10
= f.number_field :shared_runners_minutes, class: 'form-control'
.help-block
Set the maximum number of minutes that a group can use shared runners in a one month period
Set the maximum number of minutes that a group can use shared runners in a one month period. 0 for unlimited.
= link_to "(?)", help_page_path("user/admin_area/settings/continuous_integration", anchor: "shared-runners-minutes")
.form-group
= f.label :shared_runners_text, class: 'control-label col-sm-2'
......
......@@ -4,7 +4,7 @@
- if current_user && can?(current_user, :download_code, @project)
= render 'shared/no_ssh'
= render 'shared/no_password'
= render 'shared/shared_runner_minutes_limit', namespace: @project.namespace
= render 'shared/shared_runner_minutes_limit', project: @project
= render "home_panel"
......
......@@ -8,7 +8,7 @@
- if current_user && can?(current_user, :download_code, @project)
= render 'shared/no_ssh'
= render 'shared/no_password'
= render 'shared/shared_runner_minutes_limit', namespace: @project.namespace
= render 'shared/shared_runner_minutes_limit', project: @project
- if @project.above_size_limit?
= render 'above_size_limit_warning'
......
- if cookies[:hide_shared_runner_quota_message].blank? && namespace.shared_runners_minutes_used?
- project = local_assigns.fetch(:project, nil)
- namespace = local_assigns.fetch(:namespace, project && project.namespace)
- can_see_status = project.nil? || can?(current_user, :create_pipeline, project)
- if cookies[:hide_shared_runner_quota_message].blank? && namespace.shared_runners_minutes_used? && can_see_status
.shared-runner-quota-message.alert.alert-warning.hidden-xs
- if namespace.class.to_s === 'Group'
Your group has exceeded its build minutes quota.
- else
You have exceeded your build minutes quota.
Pipelines will not run anymore on shared runners.
= namespace.name
has exceeded their build minutes quota. Pipelines will not run anymore on shared runners.
.pull-right
= link_to "Don't show again this month", '#', class: 'hide-shared-runner-limit-message-one-month alert-link'
......
require 'spec_helper'
feature 'CI shared runner limits', feature: true do
let(:user) { create(:user) }
let(:project) { create(:project, :public, namespace: namespace, shared_runners_enabled: true) }
let(:namespace) { create(:namespace) }
before do
login_as(user)
end
context 'when project member' do
before do
project.team << [user, :developer]
end
context 'without limit' do
scenario 'it does not display a warning message on project homepage' do
visit namespace_project_path(project.namespace, project)
expect_no_quota_exceeded_alert
end
end
context 'when limit is defined' do
context 'when limit is exceeded' do
let(:namespace) { create(:namespace, :with_used_build_minutes_limit) }
scenario 'it displays a warning message on project homepage' do
visit namespace_project_path(project.namespace, project)
expect_quota_exceeded_alert("#{namespace.name} has exceeded their build minutes quota.")
end
end
context 'when limit not yet exceeded' do
let(:namespace) { create(:namespace, :with_not_used_build_minutes_limit) }
scenario 'it does not display a warning message on project homepage' do
visit namespace_project_path(project.namespace, project)
expect_no_quota_exceeded_alert
end
end
context 'when minutes are not yet set' do
let(:namespace) { create(:namespace, :with_build_minutes_limit) }
scenario 'it does not display a warning message on project homepage' do
visit namespace_project_path(project.namespace, project)
expect_no_quota_exceeded_alert
end
end
end
end
context 'when not a project member' do
let(:namespace) { create(:namespace, :with_used_build_minutes_limit) }
context 'when limit is defined and limit is exceeded' do
scenario 'it does not display a warning message on project homepage' do
visit namespace_project_path(project.namespace, project)
expect_no_quota_exceeded_alert
end
end
end
def expect_quota_exceeded_alert(message = nil)
expect(page).to have_selector('.shared-runner-quota-message', count: 1)
expect(page.find('.shared-runner-quota-message')).to have_content(message) unless message.nil?
end
def expect_no_quota_exceeded_alert
expect(page).not_to have_selector('.shared-runner-quota-message')
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