Commit 56906ae2 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'build-minutes-per-user-ee' into 'master'

Allow to edit build minutes per user ee

Closes gitlab-ce#30163

See merge request !1535
parents 8a426306 a555b53c
...@@ -205,7 +205,8 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -205,7 +205,8 @@ class Admin::UsersController < Admin::ApplicationController
def user_params_ee def user_params_ee
[ [
:note :note,
namespace_attributes: [:id, :shared_runners_minutes_limit]
] ]
end end
end end
...@@ -169,6 +169,8 @@ class User < ActiveRecord::Base ...@@ -169,6 +169,8 @@ class User < ActiveRecord::Base
delegate :path, to: :namespace, allow_nil: true, prefix: true delegate :path, to: :namespace, allow_nil: true, prefix: true
accepts_nested_attributes_for :namespace
state_machine :state, initial: :active do state_machine :state, initial: :active do
event :block do event :block do
transition active: :blocked transition active: :blocked
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
= render 'groups/group_lfs_settings', f: f = render 'groups/group_lfs_settings', f: f
= render 'groups/shared_runners_minutes_setting', f: f = render 'namespaces/shared_runners_minutes_setting', f: f
- if @group.new_record? - if @group.new_record?
.form-group .form-group
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
= group_lfs_status(@group) = group_lfs_status(@group)
= link_to icon('question-circle'), help_page_path('workflow/lfs/manage_large_binaries_with_git_lfs') = link_to icon('question-circle'), help_page_path('workflow/lfs/manage_large_binaries_with_git_lfs')
= render "shared_runner_status", group: @group = render partial: "namespaces/shared_runner_status", locals: { namespace: @group }
.panel.panel-default .panel.panel-default
.panel-heading Linked LDAP groups .panel-heading Linked LDAP groups
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
= render partial: 'access_levels', locals: { f: f } = render partial: 'access_levels', locals: { f: f }
= render partial: 'limits', locals: { f: f }
%fieldset %fieldset
%legend Profile %legend Profile
.form-group .form-group
......
= f.fields_for :namespace do |namespace_form|
= namespace_form.hidden_field :id
%fieldset
%legend Limits
= render "namespaces/shared_runners_minutes_setting", f: namespace_form
...@@ -123,6 +123,8 @@ ...@@ -123,6 +123,8 @@
%strong %strong
= link_to @user.created_by.name, [:admin, @user.created_by] = link_to @user.created_by.name, [:admin, @user.created_by]
= render partial: "namespaces/shared_runner_status", locals: { namespace: @user.namespace }
.col-md-6 .col-md-6
- unless @user == current_user - unless @user == current_user
- unless @user.confirmed? - unless @user.confirmed?
......
- if group.shared_runners_enabled? - namespace = local_assigns.fetch(:namespace)
- if namespace.shared_runners_enabled?
%li %li
%span.light Build minutes quota: %span.light Build minutes quota:
%strong %strong
= group_shared_runner_limits_quota(group) = group_shared_runner_limits_quota(namespace)
= link_to icon('question-circle'), help_page_path("user/admin_area/settings/continuous_integration", anchor: "shared-runners-build-minutes-quota"), target: '_blank' = link_to icon('question-circle'), help_page_path("user/admin_area/settings/continuous_integration", anchor: "shared-runners-build-minutes-quota"), target: '_blank'
---
title: Allow to edit pipelines quota for user
merge_request:
author:
...@@ -192,6 +192,40 @@ describe "Admin::Users", feature: true do ...@@ -192,6 +192,40 @@ describe "Admin::Users", feature: true do
end end
end end
end end
describe 'Shared runners quota status' do
before do
user.namespace.update(shared_runners_minutes_limit: 500)
end
context 'with projects with shared runners enabled' do
before do
create(:empty_project, namespace: user.namespace, shared_runners_enabled: true)
end
it 'shows quota' do
visit admin_users_path
click_link user.name
expect(page).to have_content('Build minutes quota: 0 / 500')
end
end
context 'without projects with shared runners enabled' do
before do
create(:empty_project, namespace: user.namespace, shared_runners_enabled: false)
end
it 'does not show quota' do
visit admin_users_path
click_link user.name
expect(page).not_to have_content('Build minutes quota:')
end
end
end
end end
describe "GET /admin/users/:id/edit" do describe "GET /admin/users/:id/edit" do
...@@ -255,6 +289,19 @@ describe "Admin::Users", feature: true do ...@@ -255,6 +289,19 @@ describe "Admin::Users", feature: true do
expect(page).to have_selector(%(form[action="/admin/users/#{user.username}"])) expect(page).to have_selector(%(form[action="/admin/users/#{user.username}"]))
end end
end end
describe 'Update shared runners quota' do
let!(:project) { create(:empty_project, namespace: user.namespace, shared_runners_enabled: true) }
before do
fill_in "user_namespace_attributes_shared_runners_minutes_limit", with: "500"
click_button "Save changes"
end
it "shows page with new data" do
expect(page).to have_content('Build minutes quota: 0 / 500')
end
end
end end
describe "GET /admin/users/:id/projects" do describe "GET /admin/users/:id/projects" do
......
...@@ -2,8 +2,7 @@ require 'spec_helper' ...@@ -2,8 +2,7 @@ require 'spec_helper'
describe ForkedProjectLink, "add link on fork" do describe ForkedProjectLink, "add link on fork" do
let(:project_from) { create(:project, :repository) } let(:project_from) { create(:project, :repository) }
let(:namespace) { create(:namespace) } let(:user) { create(:user) }
let(:user) { create(:user, namespace: namespace) }
before do before do
create(:project_member, :reporter, user: user, project: project_from) create(:project_member, :reporter, user: user, project: project_from)
......
...@@ -60,6 +60,10 @@ describe User, models: true do ...@@ -60,6 +60,10 @@ describe User, models: true do
end end
end end
describe 'nested attributes' do
it { is_expected.to respond_to(:namespace_attributes=) }
end
describe 'validations' do describe 'validations' do
describe 'username' do describe 'username' do
it 'validates presence' do it 'validates presence' do
......
...@@ -3,8 +3,8 @@ require 'spec_helper' ...@@ -3,8 +3,8 @@ require 'spec_helper'
describe Projects::ForkService, services: true do describe Projects::ForkService, services: true do
describe 'fork by user' do describe 'fork by user' do
before do before do
@from_namespace = create(:namespace) @from_user = create(:user )
@from_user = create(:user, namespace: @from_namespace ) @from_namespace = @from_user.namespace
avatar = fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png") avatar = fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")
@from_project = create(:project, @from_project = create(:project,
:repository, :repository,
...@@ -13,8 +13,8 @@ describe Projects::ForkService, services: true do ...@@ -13,8 +13,8 @@ describe Projects::ForkService, services: true do
star_count: 107, star_count: 107,
avatar: avatar, avatar: avatar,
description: 'wow such project') description: 'wow such project')
@to_namespace = create(:namespace) @to_user = create(:user)
@to_user = create(:user, namespace: @to_namespace) @to_namespace = @to_user.namespace
@from_project.add_user(@to_user, :developer) @from_project.add_user(@to_user, :developer)
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