Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-02 00:08:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-02 00:08:14 +0300
commite2ef50dafcf51e811123dd71179334de2ea3edf9 (patch)
tree2aa7d999620a93d88081b40bd7b20ac127f99270 /spec/policies
parent68d5cc2d9d162def465657d4696eb58e9b3906a7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/ci/build_policy_spec.rb48
-rw-r--r--spec/policies/project_policy_spec.rb30
2 files changed, 78 insertions, 0 deletions
diff --git a/spec/policies/ci/build_policy_spec.rb b/spec/policies/ci/build_policy_spec.rb
index 1ec749fb394..fee4d76ca8f 100644
--- a/spec/policies/ci/build_policy_spec.rb
+++ b/spec/policies/ci/build_policy_spec.rb
@@ -405,4 +405,52 @@ RSpec.describe Ci::BuildPolicy do
end
end
end
+
+ describe 'ability :create_build_terminal' do
+ let(:project) { create(:project, :private) }
+
+ subject { described_class.new(user, build) }
+
+ context 'when user can update_build' do
+ before do
+ project.add_maintainer(user)
+ end
+
+ context 'when job has terminal' do
+ before do
+ allow(build).to receive(:has_terminal?).and_return(true)
+ end
+
+ context 'when current user is the job owner' do
+ before do
+ build.update!(user: user)
+ end
+
+ it { expect_allowed(:create_build_terminal) }
+ end
+
+ context 'when current user is not the job owner' do
+ it { expect_disallowed(:create_build_terminal) }
+ end
+ end
+
+ context 'when job does not have terminal' do
+ before do
+ allow(build).to receive(:has_terminal?).and_return(false)
+ build.update!(user: user)
+ end
+
+ it { expect_disallowed(:create_build_terminal) }
+ end
+ end
+
+ context 'when user cannot update build' do
+ before do
+ project.add_guest(user)
+ allow(build).to receive(:has_terminal?).and_return(true)
+ end
+
+ it { expect_disallowed(:create_build_terminal) }
+ end
+ end
end
diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb
index ce97fc0c77e..d9316344474 100644
--- a/spec/policies/project_policy_spec.rb
+++ b/spec/policies/project_policy_spec.rb
@@ -396,6 +396,36 @@ RSpec.describe ProjectPolicy do
end
end
+ context 'importing members from another project' do
+ %w(maintainer owner).each do |role|
+ context "with #{role}" do
+ let(:current_user) { send(role) }
+
+ it { is_expected.to be_allowed(:import_project_members_from_another_project) }
+ end
+ end
+
+ %w(guest reporter developer anonymous).each do |role|
+ context "with #{role}" do
+ let(:current_user) { send(role) }
+
+ it { is_expected.to be_disallowed(:import_project_members_from_another_project) }
+ end
+ end
+
+ context 'with an admin' do
+ let(:current_user) { admin }
+
+ context 'when admin mode is enabled', :enable_admin_mode do
+ it { expect_allowed(:import_project_members_from_another_project) }
+ end
+
+ context 'when admin mode is disabled' do
+ it { expect_disallowed(:import_project_members_from_another_project) }
+ end
+ end
+ end
+
context 'reading usage quotas' do
%w(maintainer owner).each do |role|
context "with #{role}" do