Commit c5955a8d authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@13-12-stable-ee

parent aabeb0a5
......@@ -526,19 +526,22 @@
.qa:rules:package-and-qa:
rules:
- <<: *if-not-ee
when: never
when: manual
- <<: *if-dot-com-gitlab-org-and-security-merge-request
changes: *ci-qa-patterns
allow_failure: true
when: manual
- <<: *if-dot-com-gitlab-org-and-security-merge-request
changes: *qa-patterns
allow_failure: true
when: manual
- <<: *if-dot-com-gitlab-org-and-security-merge-request
changes: *code-patterns
when: manual
allow_failure: true
- <<: *if-dot-com-gitlab-org-schedule
allow_failure: true
when: manual
###############
# Rails rules #
......
......@@ -112,7 +112,7 @@ export default {
:empty-text="s__('AdminUsers|No users found')"
show-empty
stacked="md"
data-qa-selector="user_row_content"
:tbody-tr-attr="{ 'data-qa-selector': 'user_row_content' }"
>
<template #cell(name)="{ item: user }">
<user-avatar :user="user" :admin-user-path="paths.adminUser" />
......
......@@ -444,16 +444,15 @@ class Project < ApplicationRecord
delegate :members, to: :team, prefix: true
delegate :add_user, :add_users, to: :team
delegate :add_guest, :add_reporter, :add_developer, :add_maintainer, :add_role, to: :team
delegate :group_runners_enabled, :group_runners_enabled=, :group_runners_enabled?, to: :ci_cd_settings
delegate :group_runners_enabled, :group_runners_enabled=, to: :ci_cd_settings, allow_nil: true
delegate :root_ancestor, to: :namespace, allow_nil: true
delegate :last_pipeline, to: :commit, allow_nil: true
delegate :external_dashboard_url, to: :metrics_setting, allow_nil: true, prefix: true
delegate :dashboard_timezone, to: :metrics_setting, allow_nil: true, prefix: true
delegate :default_git_depth, :default_git_depth=, to: :ci_cd_settings, prefix: :ci
delegate :forward_deployment_enabled, :forward_deployment_enabled=, :forward_deployment_enabled?, to: :ci_cd_settings, prefix: :ci
delegate :keep_latest_artifact, :keep_latest_artifact=, :keep_latest_artifact?, :keep_latest_artifacts_available?, to: :ci_cd_settings
delegate :restrict_user_defined_variables, :restrict_user_defined_variables=, :restrict_user_defined_variables?,
to: :ci_cd_settings
delegate :default_git_depth, :default_git_depth=, to: :ci_cd_settings, prefix: :ci, allow_nil: true
delegate :forward_deployment_enabled, :forward_deployment_enabled=, to: :ci_cd_settings, prefix: :ci, allow_nil: true
delegate :keep_latest_artifact, :keep_latest_artifact=, to: :ci_cd_settings, allow_nil: true
delegate :restrict_user_defined_variables, :restrict_user_defined_variables=, to: :ci_cd_settings, allow_nil: true
delegate :actual_limits, :actual_plan_name, to: :namespace, allow_nil: true
delegate :allow_merge_on_skipped_pipeline, :allow_merge_on_skipped_pipeline?,
:allow_merge_on_skipped_pipeline=, :has_confluence?, :allow_editing_commit_messages?,
......@@ -2614,6 +2613,36 @@ class Project < ApplicationRecord
ProjectStatistics.increment_statistic(self, statistic, delta)
end
def ci_forward_deployment_enabled?
return false unless ci_cd_settings
ci_cd_settings.forward_deployment_enabled?
end
def restrict_user_defined_variables?
return false unless ci_cd_settings
ci_cd_settings.restrict_user_defined_variables?
end
def keep_latest_artifacts_available?
return false unless ci_cd_settings
ci_cd_settings.keep_latest_artifacts_available?
end
def keep_latest_artifact?
return false unless ci_cd_settings
ci_cd_settings.keep_latest_artifact?
end
def group_runners_enabled?
return false unless ci_cd_settings
ci_cd_settings.group_runners_enabled?
end
private
def set_container_registry_access_level
......
......@@ -9,13 +9,13 @@ module QA
Capybara.current_session
end
def confirm_user(username)
def confirm_user(user)
Flow::Login.while_signed_in_as_admin do
Page::Main::Menu.perform(&:go_to_admin_area)
Page::Admin::Menu.perform(&:go_to_users_overview)
Page::Admin::Overview::Users::Index.perform do |index|
index.search_user(username)
index.click_user(username)
index.search_user(user.email)
index.click_user(user.name)
end
Page::Admin::Overview::Users::Show.perform(&:confirm_user)
......
......@@ -11,7 +11,7 @@ module QA
element :pending_approval_tab
end
view 'app/views/admin/users/_user.html.haml' do
view 'app/assets/javascripts/admin/users/components/users_table.vue' do
element :user_row_content
end
......
......@@ -636,6 +636,47 @@ RSpec.describe Project, factory_default: :keep do
it { is_expected.to delegate_method(:root_ancestor).to(:namespace).with_arguments(allow_nil: true) }
it { is_expected.to delegate_method(:last_pipeline).to(:commit).with_arguments(allow_nil: true) }
it { is_expected.to delegate_method(:allow_editing_commit_messages?).to(:project_setting) }
include_examples 'ci_cd_settings delegation' do
# Skip attributes defined in EE code
let(:exclude_attributes) do
%w(
merge_pipelines_enabled
merge_trains_enabled
auto_rollback_enabled
)
end
end
describe '#ci_forward_deployment_enabled?' do
it_behaves_like 'a ci_cd_settings predicate method', prefix: 'ci_' do
let(:delegated_method) { :forward_deployment_enabled? }
end
end
describe '#restrict_user_defined_variables?' do
it_behaves_like 'a ci_cd_settings predicate method' do
let(:delegated_method) { :restrict_user_defined_variables? }
end
end
describe '#keep_latest_artifacts_available?' do
it_behaves_like 'a ci_cd_settings predicate method' do
let(:delegated_method) { :keep_latest_artifacts_available? }
end
end
describe '#keep_latest_artifact?' do
it_behaves_like 'a ci_cd_settings predicate method' do
let(:delegated_method) { :keep_latest_artifact? }
end
end
describe '#group_runners_enabled?' do
it_behaves_like 'a ci_cd_settings predicate method' do
let(:delegated_method) { :group_runners_enabled? }
end
end
end
describe 'reference methods' do
......
# frozen_string_literal: true
RSpec.shared_examples 'ci_cd_settings delegation' do
let(:exclude_attributes) { [] }
context 'when ci_cd_settings is destroyed but project is not' do
it 'allows methods delegated to ci_cd_settings to be nil', :aggregate_failures do
project = create(:project)
attributes = project.ci_cd_settings.attributes.keys - %w(id project_id) - exclude_attributes
project.ci_cd_settings.destroy!
project.reload
attributes.each do |attr|
method = project.respond_to?("ci_#{attr}") ? "ci_#{attr}" : attr
expect(project.send(method)).to be_nil, "#{attr} was not nil"
end
end
end
end
RSpec.shared_examples 'a ci_cd_settings predicate method' do |prefix: ''|
using RSpec::Parameterized::TableSyntax
let_it_be(:project) { create(:project) }
context 'when ci_cd_settings is nil' do
before do
allow(project).to receive(:ci_cd_settings).and_return(nil)
end
it 'returns false' do
expect(project.send("#{prefix}#{delegated_method}")).to be(false)
end
end
context 'when ci_cd_settings is not nil' do
where(:delegated_method_return, :subject_return) do
true | true
false | false
end
with_them do
let(:ci_cd_settings_double) { double('ProjectCiCdSetting') }
before do
allow(project).to receive(:ci_cd_settings).and_return(ci_cd_settings_double)
allow(ci_cd_settings_double).to receive(delegated_method).and_return(delegated_method_return)
end
it 'returns the expected boolean value' do
expect(project.send("#{prefix}#{delegated_method}")).to be(subject_return)
end
end
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