Commit 85f4d508 authored by Diego Louzán's avatar Diego Louzán Committed by Bob Van Landuyt

chore: disable auto admin mode in features

parent 79573b91
---
title: 'Disable auto admin mode in features'
merge_request: 47670
author: Diego Louzán
type: other
...@@ -4,12 +4,14 @@ require 'spec_helper' ...@@ -4,12 +4,14 @@ require 'spec_helper'
RSpec.describe 'Admin::AuditLogs', :js do RSpec.describe 'Admin::AuditLogs', :js do
include Select2Helper include Select2Helper
include AdminModeHelper
let(:user) { create(:user) } let(:user) { create(:user) }
let(:admin) { create(:admin, name: 'Bruce Wayne') } let(:admin) { create(:admin, name: 'Bruce Wayne') }
before do before do
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
context 'unlicensed' do context 'unlicensed' do
...@@ -131,6 +133,7 @@ RSpec.describe 'Admin::AuditLogs', :js do ...@@ -131,6 +133,7 @@ RSpec.describe 'Admin::AuditLogs', :js do
context 'when creation succeeds' do context 'when creation succeeds' do
before do before do
enable_admin_mode!(admin)
personal_access_token personal_access_token
end end
...@@ -157,6 +160,7 @@ RSpec.describe 'Admin::AuditLogs', :js do ...@@ -157,6 +160,7 @@ RSpec.describe 'Admin::AuditLogs', :js do
context 'when revocation succeeds' do context 'when revocation succeeds' do
before do before do
enable_admin_mode!(admin)
PersonalAccessTokens::RevokeService.new(admin, token: personal_access_token).execute PersonalAccessTokens::RevokeService.new(admin, token: personal_access_token).execute
end end
......
...@@ -6,7 +6,9 @@ RSpec.describe 'Admin::CredentialsInventory' do ...@@ -6,7 +6,9 @@ RSpec.describe 'Admin::CredentialsInventory' do
include Spec::Support::Helpers::Features::ResponsiveTableHelpers include Spec::Support::Helpers::Features::ResponsiveTableHelpers
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
context 'unlicensed' do context 'unlicensed' do
......
...@@ -7,7 +7,9 @@ RSpec.describe 'Admin Dashboard' do ...@@ -7,7 +7,9 @@ RSpec.describe 'Admin Dashboard' do
let_it_be(:users_statistics) { create(:users_statistics) } let_it_be(:users_statistics) { create(:users_statistics) }
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe 'license' do describe 'license' do
......
...@@ -8,7 +8,9 @@ RSpec.describe 'DevOps Report page', :js do ...@@ -8,7 +8,9 @@ RSpec.describe 'DevOps Report page', :js do
active_tab_selector = '.nav-link.active' active_tab_selector = '.nav-link.active'
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
context 'with devops_adoption_feature feature flag disabled' do context 'with devops_adoption_feature feature flag disabled' do
......
...@@ -6,7 +6,9 @@ RSpec.describe 'Admin::Emails', :clean_gitlab_redis_shared_state do ...@@ -6,7 +6,9 @@ RSpec.describe 'Admin::Emails', :clean_gitlab_redis_shared_state do
include ExclusiveLeaseHelpers include ExclusiveLeaseHelpers
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
context 'when `send_emails_from_admin_area` feature is not licensed' do context 'when `send_emails_from_admin_area` feature is not licensed' do
......
...@@ -10,6 +10,7 @@ RSpec.describe "Admin interacts with push rules" do ...@@ -10,6 +10,7 @@ RSpec.describe "Admin interacts with push rules" do
before do before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
sign_in(user) sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
end end
push_rules_with_titles = { push_rules_with_titles = {
......
...@@ -10,10 +10,12 @@ RSpec.describe 'Admin interacts with merge requests approvals settings' do ...@@ -10,10 +10,12 @@ RSpec.describe 'Admin interacts with merge requests approvals settings' do
let_it_be(:project) { create(:project, creator: user) } let_it_be(:project) { create(:project, creator: user) }
before do before do
sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
allow(License).to receive(:feature_available?).and_return(true) allow(License).to receive(:feature_available?).and_return(true)
sign_in(user)
visit(admin_push_rule_path) visit(admin_push_rule_path)
end end
......
...@@ -7,6 +7,7 @@ RSpec.describe 'Reset namespace pipeline minutes', :js do ...@@ -7,6 +7,7 @@ RSpec.describe 'Reset namespace pipeline minutes', :js do
before do before do
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
shared_examples 'resetting pipeline minutes' do shared_examples 'resetting pipeline minutes' do
......
...@@ -14,6 +14,7 @@ RSpec.describe "Admin sends notification", :js, :sidekiq_might_not_need_inline d ...@@ -14,6 +14,7 @@ RSpec.describe "Admin sends notification", :js, :sidekiq_might_not_need_inline d
group.add_developer(user) group.add_developer(user)
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit(admin_email_path) visit(admin_email_path)
......
...@@ -7,7 +7,9 @@ RSpec.describe 'Admin updates EE-only settings' do ...@@ -7,7 +7,9 @@ RSpec.describe 'Admin updates EE-only settings' do
before do before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
allow(License).to receive(:feature_available?).and_return(true) allow(License).to receive(:feature_available?).and_return(true)
allow(Gitlab::Elastic::Helper.default).to receive(:index_exists?).and_return(true) allow(Gitlab::Elastic::Helper.default).to receive(:index_exists?).and_return(true)
end end
......
...@@ -13,6 +13,7 @@ RSpec.describe "Admin::Users" do ...@@ -13,6 +13,7 @@ RSpec.describe "Admin::Users" do
before do before do
sign_in(current_user) sign_in(current_user)
gitlab_enable_admin_mode_sign_in(current_user)
end end
describe 'GET /admin/users' do describe 'GET /admin/users' do
......
...@@ -27,7 +27,9 @@ RSpec.describe 'admin Geo Nodes', :js, :geo do ...@@ -27,7 +27,9 @@ RSpec.describe 'admin Geo Nodes', :js, :geo do
before do before do
allow(Gitlab::Geo).to receive(:license_allows?).and_return(true) allow(Gitlab::Geo).to receive(:license_allows?).and_return(true)
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe 'index' do describe 'index' do
......
...@@ -15,7 +15,9 @@ RSpec.describe 'admin Geo Projects', :js, :geo do ...@@ -15,7 +15,9 @@ RSpec.describe 'admin Geo Projects', :js, :geo do
before do before do
allow(Gitlab::Geo).to receive(:license_allows?).and_return(true) allow(Gitlab::Geo).to receive(:license_allows?).and_return(true)
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe 'visiting geo projects initial page' do describe 'visiting geo projects initial page' do
......
...@@ -11,6 +11,7 @@ RSpec.describe 'admin Geo Replication Nav', :js, :geo do ...@@ -11,6 +11,7 @@ RSpec.describe 'admin Geo Replication Nav', :js, :geo do
before do before do
stub_licensed_features(geo: true) stub_licensed_features(geo: true)
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
stub_secondary_node stub_secondary_node
end end
......
...@@ -11,6 +11,7 @@ RSpec.describe 'admin Geo Sidebar', :js, :geo do ...@@ -11,6 +11,7 @@ RSpec.describe 'admin Geo Sidebar', :js, :geo do
before do before do
stub_licensed_features(geo: true) stub_licensed_features(geo: true)
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
shared_examples 'active sidebar link' do |link_name| shared_examples 'active sidebar link' do |link_name|
......
...@@ -8,7 +8,9 @@ RSpec.describe 'admin Geo Uploads', :js, :geo do ...@@ -8,7 +8,9 @@ RSpec.describe 'admin Geo Uploads', :js, :geo do
before do before do
allow(Gitlab::Geo).to receive(:license_allows?).and_return(true) allow(Gitlab::Geo).to receive(:license_allows?).and_return(true)
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe 'visiting geo uploads initial page' do describe 'visiting geo uploads initial page' do
......
...@@ -12,6 +12,7 @@ RSpec.describe 'Changes GL.com plan for group' do ...@@ -12,6 +12,7 @@ RSpec.describe 'Changes GL.com plan for group' do
allow(Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?) { true } allow(Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?) { true }
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe 'for group namespace' do describe 'for group namespace' do
......
...@@ -7,6 +7,7 @@ RSpec.describe "Admin uploads license", :js do ...@@ -7,6 +7,7 @@ RSpec.describe "Admin uploads license", :js do
before do before do
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
context 'default state' do context 'default state' do
......
...@@ -7,6 +7,7 @@ RSpec.describe "Admin views license" do ...@@ -7,6 +7,7 @@ RSpec.describe "Admin views license" do
before do before do
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
allow_any_instance_of(Gitlab::ExpiringSubscriptionMessage).to receive(:grace_period_effective_from).and_return(Date.today - 45.days) allow_any_instance_of(Gitlab::ExpiringSubscriptionMessage).to receive(:grace_period_effective_from).and_return(Date.today - 45.days)
end end
......
...@@ -41,10 +41,14 @@ RSpec.describe 'Display approaching user count limit banner', :js do ...@@ -41,10 +41,14 @@ RSpec.describe 'Display approaching user count limit banner', :js do
context 'when admin is logged in' do context 'when admin is logged in' do
before do before do
gitlab_sign_in(admin) sign_in(admin)
end end
context 'in admin area' do context 'in admin area' do
before do
gitlab_enable_admin_mode_sign_in(admin)
end
let(:visit_path) { admin_root_path } let(:visit_path) { admin_root_path }
it_behaves_like 'a visible banner' it_behaves_like 'a visible banner'
......
...@@ -12,6 +12,7 @@ RSpec.describe 'CI shared runner settings' do ...@@ -12,6 +12,7 @@ RSpec.describe 'CI shared runner settings' do
before do before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
context 'without global shared runners quota' do context 'without global shared runners quota' do
......
...@@ -52,6 +52,10 @@ RSpec.describe 'Clusterable > Show page' do ...@@ -52,6 +52,10 @@ RSpec.describe 'Clusterable > Show page' do
let(:cluster_path) { admin_cluster_path(cluster) } let(:cluster_path) { admin_cluster_path(cluster) }
let(:cluster) { create(:cluster, :provided_by_gcp, :instance) } let(:cluster) { create(:cluster, :provided_by_gcp, :instance) }
before do
gitlab_enable_admin_mode_sign_in(current_user)
end
it 'shows the environments tab' do it 'shows the environments tab' do
visit cluster_path visit cluster_path
......
...@@ -42,6 +42,7 @@ RSpec.describe 'GEO Nodes', :geo do ...@@ -42,6 +42,7 @@ RSpec.describe 'GEO Nodes', :geo do
stub_licensed_features(geo: true) stub_licensed_features(geo: true)
sign_in(admin_user) sign_in(admin_user)
gitlab_enable_admin_mode_sign_in(admin_user)
end end
describe 'Geo Nodes admin screen' do describe 'Geo Nodes admin screen' do
......
...@@ -5,10 +5,10 @@ RSpec.describe 'Kerberos clone instructions', :js do ...@@ -5,10 +5,10 @@ RSpec.describe 'Kerberos clone instructions', :js do
include MobileHelpers include MobileHelpers
let(:project) { create(:project, :empty_repo) } let(:project) { create(:project, :empty_repo) }
let(:admin) { create(:admin) } let(:user) { project.owner }
before do before do
sign_in(admin) sign_in(user)
allow(Gitlab.config.kerberos).to receive(:enabled).and_return(true) allow(Gitlab.config.kerberos).to receive(:enabled).and_return(true)
end end
......
...@@ -5,8 +5,8 @@ require 'spec_helper' ...@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe 'Protected Branches', :js do RSpec.describe 'Protected Branches', :js do
include ProtectedBranchHelpers include ProtectedBranchHelpers
let(:user) { create(:user, :admin) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { project.owner }
before do before do
stub_feature_flags(deploy_keys_on_protected_branches: false) stub_feature_flags(deploy_keys_on_protected_branches: false)
......
...@@ -5,8 +5,8 @@ require 'spec_helper' ...@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe 'Protected Tags', :js do RSpec.describe 'Protected Tags', :js do
include ProtectedTagHelpers include ProtectedTagHelpers
let(:user) { create(:user, :admin) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { project.owner }
before do before do
sign_in(user) sign_in(user)
......
...@@ -109,6 +109,7 @@ RSpec.describe 'Snippet elastic search', :js, :elastic, :aggregate_failures, :si ...@@ -109,6 +109,7 @@ RSpec.describe 'Snippet elastic search', :js, :elastic, :aggregate_failures, :si
context 'as administrator' do context 'as administrator' do
let(:current_user) { create(:admin) } let(:current_user) { create(:admin) }
context 'when admin mode is enabled', :enable_admin_mode do
it 'finds all snippets' do it 'finds all snippets' do
within('.results') do within('.results') do
expect(page).to have_content('public personal snippet') expect(page).to have_content('public personal snippet')
...@@ -125,6 +126,25 @@ RSpec.describe 'Snippet elastic search', :js, :elastic, :aggregate_failures, :si ...@@ -125,6 +126,25 @@ RSpec.describe 'Snippet elastic search', :js, :elastic, :aggregate_failures, :si
end end
end end
end end
context 'when admin mode is disabled' do
it 'finds only public and internal snippets' do
within('.results') do
expect(page).to have_content('public personal snippet')
expect(page).not_to have_content('public project snippet')
expect(page).to have_content('internal personal snippet')
expect(page).not_to have_content('internal project snippet')
expect(page).not_to have_content('private personal snippet')
expect(page).not_to have_content('private project snippet')
expect(page).not_to have_content('authorized personal snippet')
expect(page).not_to have_content('authorized project snippet')
end
end
end
end
end end
context 'when searching titles' do context 'when searching titles' do
......
...@@ -14,7 +14,8 @@ RSpec.describe '[EE] Private Project Access' do ...@@ -14,7 +14,8 @@ RSpec.describe '[EE] Private Project Access' do
subject { project_insights_path(project) } subject { project_insights_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:auditor) } it { is_expected.to be_allowed_for(:auditor) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
......
...@@ -7,7 +7,9 @@ RSpec.describe "Admin::AbuseReports", :js do ...@@ -7,7 +7,9 @@ RSpec.describe "Admin::AbuseReports", :js do
context 'as an admin' do context 'as an admin' do
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe 'if a user has been reported for abuse' do describe 'if a user has been reported for abuse' do
......
...@@ -4,9 +4,11 @@ require 'spec_helper' ...@@ -4,9 +4,11 @@ require 'spec_helper'
RSpec.describe 'Admin Appearance' do RSpec.describe 'Admin Appearance' do
let!(:appearance) { create(:appearance) } let!(:appearance) { create(:appearance) }
let(:admin) { create(:admin) }
it 'Create new appearance' do it 'Create new appearance' do
sign_in(create(:admin)) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit admin_appearances_path visit admin_appearances_path
fill_in 'appearance_title', with: 'MyCompany' fill_in 'appearance_title', with: 'MyCompany'
...@@ -26,7 +28,8 @@ RSpec.describe 'Admin Appearance' do ...@@ -26,7 +28,8 @@ RSpec.describe 'Admin Appearance' do
end end
it 'Preview sign-in page appearance' do it 'Preview sign-in page appearance' do
sign_in(create(:admin)) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit admin_appearances_path visit admin_appearances_path
click_link "Sign-in page" click_link "Sign-in page"
...@@ -35,7 +38,8 @@ RSpec.describe 'Admin Appearance' do ...@@ -35,7 +38,8 @@ RSpec.describe 'Admin Appearance' do
end end
it 'Preview new project page appearance' do it 'Preview new project page appearance' do
sign_in(create(:admin)) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit admin_appearances_path visit admin_appearances_path
click_link "New project page" click_link "New project page"
...@@ -45,7 +49,8 @@ RSpec.describe 'Admin Appearance' do ...@@ -45,7 +49,8 @@ RSpec.describe 'Admin Appearance' do
context 'Custom system header and footer' do context 'Custom system header and footer' do
before do before do
sign_in(create(:admin)) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
context 'when system header and footer messages are empty' do context 'when system header and footer messages are empty' do
...@@ -82,7 +87,8 @@ RSpec.describe 'Admin Appearance' do ...@@ -82,7 +87,8 @@ RSpec.describe 'Admin Appearance' do
end end
it 'Custom new project page' do it 'Custom new project page' do
sign_in create(:user) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit new_project_path visit new_project_path
expect_custom_new_project_appearance(appearance) expect_custom_new_project_appearance(appearance)
...@@ -91,6 +97,7 @@ RSpec.describe 'Admin Appearance' do ...@@ -91,6 +97,7 @@ RSpec.describe 'Admin Appearance' do
context 'Profile page with custom profile image guidelines' do context 'Profile page with custom profile image guidelines' do
before do before do
sign_in(create(:admin)) sign_in(create(:admin))
gitlab_enable_admin_mode_sign_in(admin)
visit admin_appearances_path visit admin_appearances_path
fill_in 'appearance_profile_image_guidelines', with: 'Custom profile image guidelines, please :smile:!' fill_in 'appearance_profile_image_guidelines', with: 'Custom profile image guidelines, please :smile:!'
click_button 'Update appearance settings' click_button 'Update appearance settings'
...@@ -105,7 +112,8 @@ RSpec.describe 'Admin Appearance' do ...@@ -105,7 +112,8 @@ RSpec.describe 'Admin Appearance' do
end end
it 'Appearance logo' do it 'Appearance logo' do
sign_in(create(:admin)) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit admin_appearances_path visit admin_appearances_path
attach_file(:appearance_logo, logo_fixture) attach_file(:appearance_logo, logo_fixture)
...@@ -117,7 +125,8 @@ RSpec.describe 'Admin Appearance' do ...@@ -117,7 +125,8 @@ RSpec.describe 'Admin Appearance' do
end end
it 'Header logos' do it 'Header logos' do
sign_in(create(:admin)) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit admin_appearances_path visit admin_appearances_path
attach_file(:appearance_header_logo, logo_fixture) attach_file(:appearance_header_logo, logo_fixture)
...@@ -129,7 +138,8 @@ RSpec.describe 'Admin Appearance' do ...@@ -129,7 +138,8 @@ RSpec.describe 'Admin Appearance' do
end end
it 'Favicon' do it 'Favicon' do
sign_in(create(:admin)) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit admin_appearances_path visit admin_appearances_path
attach_file(:appearance_favicon, logo_fixture) attach_file(:appearance_favicon, logo_fixture)
......
...@@ -4,7 +4,9 @@ require 'spec_helper' ...@@ -4,7 +4,9 @@ require 'spec_helper'
RSpec.describe 'Admin Broadcast Messages' do RSpec.describe 'Admin Broadcast Messages' do
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
create(:broadcast_message, :expired, message: 'Migration to new server') create(:broadcast_message, :expired, message: 'Migration to new server')
visit admin_broadcast_messages_path visit admin_broadcast_messages_path
end end
......
...@@ -6,7 +6,9 @@ RSpec.describe 'Admin browse spam logs' do ...@@ -6,7 +6,9 @@ RSpec.describe 'Admin browse spam logs' do
let!(:spam_log) { create(:spam_log, description: 'abcde ' * 20) } let!(:spam_log) { create(:spam_log, description: 'abcde ' * 20) }
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
it 'Browse spam logs' do it 'Browse spam logs' do
......
...@@ -4,7 +4,9 @@ require 'spec_helper' ...@@ -4,7 +4,9 @@ require 'spec_helper'
RSpec.describe 'Admin Builds' do RSpec.describe 'Admin Builds' do
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe 'GET /admin/builds' do describe 'GET /admin/builds' do
......
...@@ -4,7 +4,9 @@ require 'spec_helper' ...@@ -4,7 +4,9 @@ require 'spec_helper'
RSpec.describe 'Cohorts page' do RSpec.describe 'Cohorts page' do
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
context 'with usage ping enabled' do context 'with usage ping enabled' do
......
...@@ -7,7 +7,9 @@ RSpec.describe 'admin deploy keys' do ...@@ -7,7 +7,9 @@ RSpec.describe 'admin deploy keys' do
let!(:another_deploy_key) { create(:another_deploy_key, public: true) } let!(:another_deploy_key) { create(:another_deploy_key, public: true) }
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
it 'show all public deploy keys' do it 'show all public deploy keys' do
......
...@@ -4,7 +4,9 @@ require 'spec_helper' ...@@ -4,7 +4,9 @@ require 'spec_helper'
RSpec.describe 'DevOps Report page', :js do RSpec.describe 'DevOps Report page', :js do
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
context 'with devops_adoption feature flag disabled' do context 'with devops_adoption feature flag disabled' do
......
...@@ -12,6 +12,7 @@ RSpec.describe 'Admin disables Git access protocol', :js do ...@@ -12,6 +12,7 @@ RSpec.describe 'Admin disables Git access protocol', :js do
before do before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
context 'with HTTP disabled' do context 'with HTTP disabled' do
......
...@@ -4,7 +4,9 @@ require 'spec_helper' ...@@ -4,7 +4,9 @@ require 'spec_helper'
RSpec.describe 'Admin disables 2FA for a user' do RSpec.describe 'Admin disables 2FA for a user' do
it 'successfully', :js do it 'successfully', :js do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
user = create(:user, :two_factor) user = create(:user, :two_factor)
edit_user(user) edit_user(user)
...@@ -19,7 +21,9 @@ RSpec.describe 'Admin disables 2FA for a user' do ...@@ -19,7 +21,9 @@ RSpec.describe 'Admin disables 2FA for a user' do
end end
it 'for a user without 2FA enabled' do it 'for a user without 2FA enabled' do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
user = create(:user) user = create(:user)
edit_user(user) edit_user(user)
......
...@@ -13,6 +13,7 @@ RSpec.describe 'Admin Groups' do ...@@ -13,6 +13,7 @@ RSpec.describe 'Admin Groups' do
before do before do
sign_in(current_user) sign_in(current_user)
gitlab_enable_admin_mode_sign_in(current_user)
stub_application_setting(default_group_visibility: internal) stub_application_setting(default_group_visibility: internal)
end end
......
...@@ -9,6 +9,7 @@ RSpec.describe "Admin Health Check", :feature do ...@@ -9,6 +9,7 @@ RSpec.describe "Admin Health Check", :feature do
before do before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe '#show' do describe '#show' do
......
...@@ -8,7 +8,9 @@ RSpec.describe 'Admin::HookLogs' do ...@@ -8,7 +8,9 @@ RSpec.describe 'Admin::HookLogs' do
let(:hook_log) { create(:web_hook_log, web_hook: system_hook, internal_error_message: 'some error') } let(:hook_log) { create(:web_hook_log, web_hook: system_hook, internal_error_message: 'some error') }
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
it 'show list of hook logs' do it 'show list of hook logs' do
......
...@@ -7,6 +7,7 @@ RSpec.describe 'Admin::Hooks' do ...@@ -7,6 +7,7 @@ RSpec.describe 'Admin::Hooks' do
before do before do
sign_in(user) sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
end end
describe 'GET /admin/hooks' do describe 'GET /admin/hooks' do
......
...@@ -7,7 +7,9 @@ RSpec.describe 'admin issues labels' do ...@@ -7,7 +7,9 @@ RSpec.describe 'admin issues labels' do
let!(:feature_label) { Label.create(title: 'feature', template: true) } let!(:feature_label) { Label.create(title: 'feature', template: true) }
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe 'list' do describe 'list' do
......
...@@ -4,7 +4,9 @@ require 'spec_helper' ...@@ -4,7 +4,9 @@ require 'spec_helper'
RSpec.describe 'admin manage applications' do RSpec.describe 'admin manage applications' do
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
it 'creates new oauth application' do it 'creates new oauth application' do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_mock_admin_mode do RSpec.describe 'Admin Mode Login' do
include TermsHelper include TermsHelper
include UserLoginHelper include UserLoginHelper
include LdapHelpers include LdapHelpers
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Admin Mode Logout', :js, :clean_gitlab_redis_shared_state, :do_not_mock_admin_mode do RSpec.describe 'Admin Mode Logout', :js do
include TermsHelper include TermsHelper
include UserLoginHelper include UserLoginHelper
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
# Test an operation that triggers background jobs requiring administrative rights # Test an operation that triggers background jobs requiring administrative rights
RSpec.describe 'Admin mode for workers', :do_not_mock_admin_mode, :request_store, :clean_gitlab_redis_shared_state do RSpec.describe 'Admin mode for workers', :request_store do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user_to_delete) { create(:user) } let(:user_to_delete) { create(:user) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Admin mode', :clean_gitlab_redis_shared_state, :do_not_mock_admin_mode do RSpec.describe 'Admin mode' do
include MobileHelpers include MobileHelpers
include StubENV include StubENV
......
...@@ -11,6 +11,7 @@ RSpec.describe "Admin::Projects" do ...@@ -11,6 +11,7 @@ RSpec.describe "Admin::Projects" do
before do before do
sign_in(current_user) sign_in(current_user)
gitlab_enable_admin_mode_sign_in(current_user)
end end
describe "GET /admin/projects" do describe "GET /admin/projects" do
......
...@@ -7,7 +7,9 @@ RSpec.describe 'Admin::RequestsProfilesController' do ...@@ -7,7 +7,9 @@ RSpec.describe 'Admin::RequestsProfilesController' do
before do before do
stub_const('Gitlab::RequestProfiler::PROFILES_DIR', tmpdir) stub_const('Gitlab::RequestProfiler::PROFILES_DIR', tmpdir)
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
after do after do
......
...@@ -9,7 +9,9 @@ RSpec.describe "Admin Runners" do ...@@ -9,7 +9,9 @@ RSpec.describe "Admin Runners" do
before do before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe "Runners page" do describe "Runners page" do
......
...@@ -7,6 +7,7 @@ RSpec.describe "Admin > Admin sees project statistics" do ...@@ -7,6 +7,7 @@ RSpec.describe "Admin > Admin sees project statistics" do
before do before do
sign_in(current_user) sign_in(current_user)
gitlab_enable_admin_mode_sign_in(current_user)
visit admin_project_path(project) visit admin_project_path(project)
end end
......
...@@ -10,6 +10,7 @@ RSpec.describe "Admin > Admin sees projects statistics" do ...@@ -10,6 +10,7 @@ RSpec.describe "Admin > Admin sees projects statistics" do
create(:project, :repository) { |project| project.statistics.destroy } create(:project, :repository) { |project| project.statistics.destroy }
sign_in(current_user) sign_in(current_user)
gitlab_enable_admin_mode_sign_in(current_user)
visit admin_projects_path visit admin_projects_path
end end
......
...@@ -7,7 +7,9 @@ RSpec.describe 'Admin Serverless Domains', :js do ...@@ -7,7 +7,9 @@ RSpec.describe 'Admin Serverless Domains', :js do
before do before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true) allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
it 'Add domain with certificate' do it 'Add domain with certificate' do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Admin updates settings', :clean_gitlab_redis_shared_state, :do_not_mock_admin_mode do RSpec.describe 'Admin updates settings' do
include StubENV include StubENV
include TermsHelper include TermsHelper
include UsageDataHelpers include UsageDataHelpers
......
...@@ -4,7 +4,9 @@ require 'spec_helper' ...@@ -4,7 +4,9 @@ require 'spec_helper'
RSpec.describe 'Admin System Info' do RSpec.describe 'Admin System Info' do
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe 'GET /admin/system_info' do describe 'GET /admin/system_info' do
......
...@@ -20,6 +20,7 @@ RSpec.describe 'Admin > Users > Impersonation Tokens', :js do ...@@ -20,6 +20,7 @@ RSpec.describe 'Admin > Users > Impersonation Tokens', :js do
before do before do
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe "token creation" do describe "token creation" do
......
...@@ -13,6 +13,7 @@ RSpec.describe "Admin::Users" do ...@@ -13,6 +13,7 @@ RSpec.describe "Admin::Users" do
before do before do
sign_in(current_user) sign_in(current_user)
gitlab_enable_admin_mode_sign_in(current_user)
end end
describe "GET /admin/users" do describe "GET /admin/users" do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Admin uses repository checks', :request_store, :clean_gitlab_redis_shared_state, :do_not_mock_admin_mode do RSpec.describe 'Admin uses repository checks', :request_store do
include StubENV include StubENV
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
......
...@@ -10,6 +10,7 @@ RSpec.describe 'Instance-level Cluster Applications', :js do ...@@ -10,6 +10,7 @@ RSpec.describe 'Instance-level Cluster Applications', :js do
before do before do
sign_in(user) sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
end end
describe 'Installing applications' do describe 'Installing applications' do
......
...@@ -7,6 +7,7 @@ RSpec.describe 'Instance-level AWS EKS Cluster', :js do ...@@ -7,6 +7,7 @@ RSpec.describe 'Instance-level AWS EKS Cluster', :js do
before do before do
sign_in(user) sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
end end
context 'when user does not have a cluster and visits group clusters page' do context 'when user does not have a cluster and visits group clusters page' do
......
...@@ -6,7 +6,9 @@ RSpec.describe 'admin visits dashboard' do ...@@ -6,7 +6,9 @@ RSpec.describe 'admin visits dashboard' do
include ProjectForksHelper include ProjectForksHelper
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
context 'counting forks', :js do context 'counting forks', :js do
......
...@@ -7,6 +7,7 @@ RSpec.describe 'Admin activates Prometheus', :js do ...@@ -7,6 +7,7 @@ RSpec.describe 'Admin activates Prometheus', :js do
before do before do
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit(admin_application_settings_services_path) visit(admin_application_settings_services_path)
......
...@@ -8,6 +8,7 @@ RSpec.describe 'Admin visits service templates' do ...@@ -8,6 +8,7 @@ RSpec.describe 'Admin visits service templates' do
before do before do
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit(admin_application_settings_services_path) visit(admin_application_settings_services_path)
end end
......
...@@ -9,7 +9,9 @@ RSpec.describe 'Issue Boards shortcut', :js do ...@@ -9,7 +9,9 @@ RSpec.describe 'Issue Boards shortcut', :js do
before do before do
create(:board, project: project) create(:board, project: project)
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit project_path(project) visit project_path(project)
end end
...@@ -26,7 +28,9 @@ RSpec.describe 'Issue Boards shortcut', :js do ...@@ -26,7 +28,9 @@ RSpec.describe 'Issue Boards shortcut', :js do
let(:project) { create(:project, :issues_disabled) } let(:project) { create(:project, :issues_disabled) }
before do before do
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit project_path(project) visit project_path(project)
end end
......
...@@ -168,6 +168,10 @@ RSpec.describe 'Clusterable > Show page' do ...@@ -168,6 +168,10 @@ RSpec.describe 'Clusterable > Show page' do
let(:cluster_path) { admin_cluster_path(cluster) } let(:cluster_path) { admin_cluster_path(cluster) }
let(:cluster) { create(:cluster, :provided_by_gcp, :instance) } let(:cluster) { create(:cluster, :provided_by_gcp, :instance) }
before do
gitlab_enable_admin_mode_sign_in(current_user)
end
it_behaves_like 'show page' do it_behaves_like 'show page' do
let(:cluster_type_label) { 'Instance cluster' } let(:cluster_type_label) { 'Instance cluster' }
end end
......
...@@ -10,7 +10,9 @@ RSpec.describe 'Expand and collapse diffs', :js do ...@@ -10,7 +10,9 @@ RSpec.describe 'Expand and collapse diffs', :js do
stub_feature_flags(increased_diff_limits: false) stub_feature_flags(increased_diff_limits: false)
allow(Gitlab::CurrentSettings).to receive(:diff_max_patch_bytes).and_return(100.kilobytes) allow(Gitlab::CurrentSettings).to receive(:diff_max_patch_bytes).and_return(100.kilobytes)
sign_in(create(:admin)) admin = create(:admin)
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
# Ensure that undiffable.md is in .gitattributes # Ensure that undiffable.md is in .gitattributes
project.repository.copy_gitattributes(branch) project.repository.copy_gitattributes(branch)
......
...@@ -6,7 +6,7 @@ RSpec.describe 'Upload a git lfs object', :js do ...@@ -6,7 +6,7 @@ RSpec.describe 'Upload a git lfs object', :js do
include_context 'file upload requests helpers' include_context 'file upload requests helpers'
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user, :admin) } let_it_be(:user) { project.owner }
let_it_be(:personal_access_token) { create(:personal_access_token, user: user) } let_it_be(:personal_access_token) { create(:personal_access_token, user: user) }
let(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif') } let(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif') }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Group' do RSpec.describe 'Group' do
let(:user) { create(:admin) } let(:user) { create(:user) }
before do before do
sign_in(user) sign_in(user)
...@@ -21,8 +21,6 @@ RSpec.describe 'Group' do ...@@ -21,8 +21,6 @@ RSpec.describe 'Group' do
end end
describe 'as a non-admin' do describe 'as a non-admin' do
let(:user) { create(:user) }
it 'creates a group and persists visibility radio selection', :js do it 'creates a group and persists visibility radio selection', :js do
stub_application_setting(default_group_visibility: :private) stub_application_setting(default_group_visibility: :private)
...@@ -140,6 +138,8 @@ RSpec.describe 'Group' do ...@@ -140,6 +138,8 @@ RSpec.describe 'Group' do
let(:group) { create(:group, path: 'foo') } let(:group) { create(:group, path: 'foo') }
context 'as admin' do context 'as admin' do
let(:user) { create(:admin) }
before do before do
visit new_group_path(group, parent_id: group.id) visit new_group_path(group, parent_id: group.id)
end end
...@@ -190,6 +190,8 @@ RSpec.describe 'Group' do ...@@ -190,6 +190,8 @@ RSpec.describe 'Group' do
let(:new_name) { 'new-name' } let(:new_name) { 'new-name' }
before do before do
group.add_owner(user)
visit path visit path
end end
...@@ -200,6 +202,8 @@ RSpec.describe 'Group' do ...@@ -200,6 +202,8 @@ RSpec.describe 'Group' do
it 'saves new settings' do it 'saves new settings' do
page.within('.gs-general') do page.within('.gs-general') do
# Have to reset it to '' so it overwrites rather than appends
fill_in('group_name', with: '')
fill_in 'group_name', with: new_name fill_in 'group_name', with: new_name
click_button 'Save changes' click_button 'Save changes'
end end
...@@ -229,6 +233,10 @@ RSpec.describe 'Group' do ...@@ -229,6 +233,10 @@ RSpec.describe 'Group' do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:path) { group_path(group) } let(:path) { group_path(group) }
before do
group.add_owner(user)
end
it 'parses Markdown' do it 'parses Markdown' do
group.update_attribute(:description, 'This is **my** group') group.update_attribute(:description, 'This is **my** group')
...@@ -267,6 +275,10 @@ RSpec.describe 'Group' do ...@@ -267,6 +275,10 @@ RSpec.describe 'Group' do
let!(:nested_group) { create(:group, parent: group) } let!(:nested_group) { create(:group, parent: group) }
let!(:project) { create(:project, namespace: group) } let!(:project) { create(:project, namespace: group) }
before do
group.add_owner(user)
end
it 'renders projects and groups on the page' do it 'renders projects and groups on the page' do
visit group_path(group) visit group_path(group)
wait_for_requests wait_for_requests
...@@ -294,6 +306,10 @@ RSpec.describe 'Group' do ...@@ -294,6 +306,10 @@ RSpec.describe 'Group' do
describe 'new subgroup / project button' do describe 'new subgroup / project button' do
let(:group) { create(:group, project_creation_level: Gitlab::Access::NO_ONE_PROJECT_ACCESS, subgroup_creation_level: Gitlab::Access::OWNER_SUBGROUP_ACCESS) } let(:group) { create(:group, project_creation_level: Gitlab::Access::NO_ONE_PROJECT_ACCESS, subgroup_creation_level: Gitlab::Access::OWNER_SUBGROUP_ACCESS) }
before do
group.add_owner(user)
end
context 'when user has subgroup creation permissions but not project creation permissions' do context 'when user has subgroup creation permissions but not project creation permissions' do
it 'only displays "New subgroup" button' do it 'only displays "New subgroup" button' do
visit group_path(group) visit group_path(group)
......
...@@ -8,7 +8,7 @@ RSpec.describe 'Issues shortcut', :js do ...@@ -8,7 +8,7 @@ RSpec.describe 'Issues shortcut', :js do
let(:project) { create(:project) } let(:project) { create(:project) }
before do before do
sign_in(create(:admin)) sign_in(project.owner)
visit project_path(project) visit project_path(project)
end end
...@@ -23,7 +23,7 @@ RSpec.describe 'Issues shortcut', :js do ...@@ -23,7 +23,7 @@ RSpec.describe 'Issues shortcut', :js do
let(:project) { create(:project, :issues_disabled) } let(:project) { create(:project, :issues_disabled) }
before do before do
sign_in(create(:admin)) sign_in(project.owner)
visit project_path(project) visit project_path(project)
end end
......
...@@ -7,10 +7,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -7,10 +7,6 @@ RSpec.describe 'Copy as GFM', :js do
include RepoHelpers include RepoHelpers
include ActionView::Helpers::JavaScriptHelper include ActionView::Helpers::JavaScriptHelper
before do
sign_in(create(:admin))
end
describe 'Copying rendered GFM' do describe 'Copying rendered GFM' do
before do before do
@feat = MarkdownFeature.new @feat = MarkdownFeature.new
...@@ -18,6 +14,9 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -18,6 +14,9 @@ RSpec.describe 'Copy as GFM', :js do
# `markdown` helper expects a `@project` variable # `markdown` helper expects a `@project` variable
@project = @feat.project @project = @feat.project
user = create(:user)
@project.add_maintainer(user)
sign_in(user)
visit project_issue_path(@project, @feat.issue) visit project_issue_path(@project, @feat.issue)
end end
...@@ -650,6 +649,10 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -650,6 +649,10 @@ RSpec.describe 'Copy as GFM', :js do
describe 'Copying code' do describe 'Copying code' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
before do
sign_in(project.owner)
end
context 'from a diff' do context 'from a diff' do
shared_examples 'copying code from a diff' do shared_examples 'copying code from a diff' do
context 'selecting one word of text' do context 'selecting one word of text' do
......
...@@ -45,6 +45,7 @@ RSpec.describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state do ...@@ -45,6 +45,7 @@ RSpec.describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state do
) )
gitlab_sign_in(admin) gitlab_sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit admin_user_path(user) visit admin_user_path(user)
......
...@@ -9,12 +9,9 @@ RSpec.describe 'User creates new blob', :js do ...@@ -9,12 +9,9 @@ RSpec.describe 'User creates new blob', :js do
let(:project) { create(:project, :empty_repo) } let(:project) { create(:project, :empty_repo) }
shared_examples 'creating a file' do shared_examples 'creating a file' do
before do it 'allows the user to add a new file in Web IDE' do
sign_in(user)
visit project_path(project) visit project_path(project)
end
it 'allows the user to add a new file in Web IDE' do
click_link 'New file' click_link 'New file'
wait_for_requests wait_for_requests
...@@ -31,6 +28,7 @@ RSpec.describe 'User creates new blob', :js do ...@@ -31,6 +28,7 @@ RSpec.describe 'User creates new blob', :js do
describe 'as a maintainer' do describe 'as a maintainer' do
before do before do
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user)
end end
it_behaves_like 'creating a file' it_behaves_like 'creating a file'
...@@ -39,6 +37,11 @@ RSpec.describe 'User creates new blob', :js do ...@@ -39,6 +37,11 @@ RSpec.describe 'User creates new blob', :js do
describe 'as an admin' do describe 'as an admin' do
let(:user) { create(:user, :admin) } let(:user) { create(:user, :admin) }
before do
sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
end
it_behaves_like 'creating a file' it_behaves_like 'creating a file'
end end
......
...@@ -5,8 +5,8 @@ require 'spec_helper' ...@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe 'User follows pipeline suggest nudge spec when feature is enabled', :js do RSpec.describe 'User follows pipeline suggest nudge spec when feature is enabled', :js do
include CookieHelper include CookieHelper
let(:user) { create(:user, :admin) }
let(:project) { create(:project, :empty_repo) } let(:project) { create(:project, :empty_repo) }
let(:user) { project.owner }
describe 'viewing the new blob page' do describe 'viewing the new blob page' do
before do before do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Gcp Cluster', :js, :do_not_mock_admin_mode do RSpec.describe 'Gcp Cluster', :js do
include GoogleApi::CloudPlatformHelpers include GoogleApi::CloudPlatformHelpers
let(:project) { create(:project) } let(:project) { create(:project) }
......
...@@ -150,6 +150,7 @@ RSpec.describe 'Edit Project Settings' do ...@@ -150,6 +150,7 @@ RSpec.describe 'Edit Project Settings' do
before do before do
non_member.update_attribute(:admin, true) non_member.update_attribute(:admin, true)
sign_in(non_member) sign_in(non_member)
gitlab_enable_admin_mode_sign_in(non_member)
end end
it 'renders 404 if feature is disabled' do it 'renders 404 if feature is disabled' do
......
...@@ -6,7 +6,7 @@ RSpec.describe 'GFM autocomplete loading', :js do ...@@ -6,7 +6,7 @@ RSpec.describe 'GFM autocomplete loading', :js do
let(:project) { create(:project) } let(:project) { create(:project) }
before do before do
sign_in(create(:admin)) sign_in(project.owner)
visit project_path(project) visit project_path(project)
end end
......
...@@ -289,13 +289,13 @@ RSpec.describe 'Projects > Settings > Repository settings' do ...@@ -289,13 +289,13 @@ RSpec.describe 'Projects > Settings > Repository settings' do
visit project_settings_repository_path(project) visit project_settings_repository_path(project)
end end
context 'when project mirroring is enabled' do context 'when project mirroring is enabled', :enable_admin_mode do
let(:mirror_available) { true } let(:mirror_available) { true }
include_examples 'shows mirror settings' include_examples 'shows mirror settings'
end end
context 'when project mirroring is disabled' do context 'when project mirroring is disabled', :enable_admin_mode do
let(:mirror_available) { false } let(:mirror_available) { false }
include_examples 'shows mirror settings' include_examples 'shows mirror settings'
......
...@@ -7,12 +7,9 @@ RSpec.describe 'User views an empty project' do ...@@ -7,12 +7,9 @@ RSpec.describe 'User views an empty project' do
let(:user) { create(:user) } let(:user) { create(:user) }
shared_examples 'allowing push to default branch' do shared_examples 'allowing push to default branch' do
before do it 'shows push-to-master instructions' do
sign_in(user)
visit project_path(project) visit project_path(project)
end
it 'shows push-to-master instructions' do
expect(page).to have_content('git push -u origin master') expect(page).to have_content('git push -u origin master')
end end
end end
...@@ -20,6 +17,7 @@ RSpec.describe 'User views an empty project' do ...@@ -20,6 +17,7 @@ RSpec.describe 'User views an empty project' do
describe 'as a maintainer' do describe 'as a maintainer' do
before do before do
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user)
end end
it_behaves_like 'allowing push to default branch' it_behaves_like 'allowing push to default branch'
...@@ -28,17 +26,33 @@ RSpec.describe 'User views an empty project' do ...@@ -28,17 +26,33 @@ RSpec.describe 'User views an empty project' do
describe 'as an admin' do describe 'as an admin' do
let(:user) { create(:user, :admin) } let(:user) { create(:user, :admin) }
context 'when admin mode is enabled' do
before do
sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
end
it_behaves_like 'allowing push to default branch' it_behaves_like 'allowing push to default branch'
end end
context 'when admin mode is disabled' do
it 'does not show push-to-master instructions' do
visit project_path(project)
expect(page).not_to have_content('git push -u origin master')
end
end
end
describe 'as a developer' do describe 'as a developer' do
before do before do
project.add_developer(user) project.add_developer(user)
sign_in(user) sign_in(user)
visit project_path(project)
end end
it 'does not show push-to-master instructions' do it 'does not show push-to-master instructions' do
visit project_path(project)
expect(page).not_to have_content('git push -u origin master') expect(page).not_to have_content('git push -u origin master')
end end
end end
......
...@@ -61,7 +61,7 @@ RSpec.describe 'Project' do ...@@ -61,7 +61,7 @@ RSpec.describe 'Project' do
let(:path) { project_path(project) } let(:path) { project_path(project) }
before do before do
sign_in(create(:admin)) sign_in(project.owner)
end end
it 'parses Markdown' do it 'parses Markdown' do
...@@ -125,7 +125,7 @@ RSpec.describe 'Project' do ...@@ -125,7 +125,7 @@ RSpec.describe 'Project' do
let(:path) { project_path(project) } let(:path) { project_path(project) }
before do before do
sign_in(create(:admin)) sign_in(project.owner)
visit path visit path
end end
...@@ -156,7 +156,7 @@ RSpec.describe 'Project' do ...@@ -156,7 +156,7 @@ RSpec.describe 'Project' do
let(:path) { project_path(project) } let(:path) { project_path(project) }
before do before do
sign_in(create(:admin)) sign_in(project.owner)
visit path visit path
end end
......
...@@ -73,6 +73,7 @@ RSpec.describe 'Protected Branches', :js do ...@@ -73,6 +73,7 @@ RSpec.describe 'Protected Branches', :js do
context 'logged in as admin' do context 'logged in as admin' do
before do before do
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
end end
describe "explicit protected branches" do describe "explicit protected branches" do
......
...@@ -5,8 +5,8 @@ require 'spec_helper' ...@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe 'Protected Tags', :js do RSpec.describe 'Protected Tags', :js do
include ProtectedTagHelpers include ProtectedTagHelpers
let(:user) { create(:user, :admin) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { project.owner }
before do before do
sign_in(user) sign_in(user)
......
...@@ -8,7 +8,14 @@ RSpec.describe "Admin::Projects" do ...@@ -8,7 +8,14 @@ RSpec.describe "Admin::Projects" do
describe "GET /admin/projects" do describe "GET /admin/projects" do
subject { admin_projects_path } subject { admin_projects_path }
context 'when admin mode is enabled', :enable_admin_mode do
it { is_expected.to be_allowed_for :admin } it { is_expected.to be_allowed_for :admin }
end
context 'when admin mode is disabled' do
it { is_expected.to be_denied_for :admin }
end
it { is_expected.to be_denied_for :user } it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor } it { is_expected.to be_denied_for :visitor }
end end
...@@ -16,7 +23,14 @@ RSpec.describe "Admin::Projects" do ...@@ -16,7 +23,14 @@ RSpec.describe "Admin::Projects" do
describe "GET /admin/users" do describe "GET /admin/users" do
subject { admin_users_path } subject { admin_users_path }
context 'when admin mode is enabled', :enable_admin_mode do
it { is_expected.to be_allowed_for :admin } it { is_expected.to be_allowed_for :admin }
end
context 'when admin mode is disabled' do
it { is_expected.to be_denied_for :admin }
end
it { is_expected.to be_denied_for :user } it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor } it { is_expected.to be_denied_for :visitor }
end end
...@@ -24,7 +38,14 @@ RSpec.describe "Admin::Projects" do ...@@ -24,7 +38,14 @@ RSpec.describe "Admin::Projects" do
describe "GET /admin/hooks" do describe "GET /admin/hooks" do
subject { admin_hooks_path } subject { admin_hooks_path }
context 'when admin mode is enabled', :enable_admin_mode do
it { is_expected.to be_allowed_for :admin } it { is_expected.to be_allowed_for :admin }
end
context 'when admin mode is disabled' do
it { is_expected.to be_denied_for :admin }
end
it { is_expected.to be_denied_for :user } it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor } it { is_expected.to be_denied_for :visitor }
end end
......
...@@ -102,7 +102,8 @@ RSpec.describe "Internal Project Access" do ...@@ -102,7 +102,8 @@ RSpec.describe "Internal Project Access" do
describe "GET /:project_path/-/settings/ci_cd" do describe "GET /:project_path/-/settings/ci_cd" do
subject { project_settings_ci_cd_path(project) } subject { project_settings_ci_cd_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -116,7 +117,8 @@ RSpec.describe "Internal Project Access" do ...@@ -116,7 +117,8 @@ RSpec.describe "Internal Project Access" do
describe "GET /:project_path/-/settings/repository" do describe "GET /:project_path/-/settings/repository" do
subject { project_settings_repository_path(project) } subject { project_settings_repository_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -146,7 +148,8 @@ RSpec.describe "Internal Project Access" do ...@@ -146,7 +148,8 @@ RSpec.describe "Internal Project Access" do
describe "GET /:project_path/edit" do describe "GET /:project_path/edit" do
subject { edit_project_path(project) } subject { edit_project_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -160,7 +163,8 @@ RSpec.describe "Internal Project Access" do ...@@ -160,7 +163,8 @@ RSpec.describe "Internal Project Access" do
describe "GET /:project_path/deploy_keys" do describe "GET /:project_path/deploy_keys" do
subject { project_deploy_keys_path(project) } subject { project_deploy_keys_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -190,7 +194,8 @@ RSpec.describe "Internal Project Access" do ...@@ -190,7 +194,8 @@ RSpec.describe "Internal Project Access" do
subject { edit_project_issue_path(project, issue) } subject { edit_project_issue_path(project, issue) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -218,7 +223,8 @@ RSpec.describe "Internal Project Access" do ...@@ -218,7 +223,8 @@ RSpec.describe "Internal Project Access" do
describe "GET /:project_path/snippets/new" do describe "GET /:project_path/snippets/new" do
subject { new_project_snippet_path(project) } subject { new_project_snippet_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -246,7 +252,8 @@ RSpec.describe "Internal Project Access" do ...@@ -246,7 +252,8 @@ RSpec.describe "Internal Project Access" do
describe "GET /:project_path/-/merge_requests/new" do describe "GET /:project_path/-/merge_requests/new" do
subject { project_new_merge_request_path(project) } subject { project_new_merge_request_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -302,7 +309,8 @@ RSpec.describe "Internal Project Access" do ...@@ -302,7 +309,8 @@ RSpec.describe "Internal Project Access" do
describe "GET /:project_path/-/settings/integrations" do describe "GET /:project_path/-/settings/integrations" do
subject { project_settings_integrations_path(project) } subject { project_settings_integrations_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -367,7 +375,8 @@ RSpec.describe "Internal Project Access" do ...@@ -367,7 +375,8 @@ RSpec.describe "Internal Project Access" do
project.update(public_builds: false) project.update(public_builds: false)
end end
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -406,7 +415,8 @@ RSpec.describe "Internal Project Access" do ...@@ -406,7 +415,8 @@ RSpec.describe "Internal Project Access" do
project.update(public_builds: false) project.update(public_builds: false)
end end
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -445,7 +455,8 @@ RSpec.describe "Internal Project Access" do ...@@ -445,7 +455,8 @@ RSpec.describe "Internal Project Access" do
project.update(public_builds: false) project.update(public_builds: false)
end end
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -460,7 +471,8 @@ RSpec.describe "Internal Project Access" do ...@@ -460,7 +471,8 @@ RSpec.describe "Internal Project Access" do
describe "GET /:project_path/pipeline_schedules" do describe "GET /:project_path/pipeline_schedules" do
subject { project_pipeline_schedules_path(project) } subject { project_pipeline_schedules_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is allowed for admin when admin mode is disabled') { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -474,7 +486,8 @@ RSpec.describe "Internal Project Access" do ...@@ -474,7 +486,8 @@ RSpec.describe "Internal Project Access" do
describe "GET /:project_path/-/environments" do describe "GET /:project_path/-/environments" do
subject { project_environments_path(project) } subject { project_environments_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is allowed for admin when admin mode is disabled') { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -490,7 +503,8 @@ RSpec.describe "Internal Project Access" do ...@@ -490,7 +503,8 @@ RSpec.describe "Internal Project Access" do
subject { project_environment_path(project, environment) } subject { project_environment_path(project, environment) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is allowed for admin when admin mode is disabled') { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -506,7 +520,8 @@ RSpec.describe "Internal Project Access" do ...@@ -506,7 +520,8 @@ RSpec.describe "Internal Project Access" do
subject { project_environment_deployments_path(project, environment) } subject { project_environment_deployments_path(project, environment) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is allowed for admin when admin mode is disabled') { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -520,7 +535,8 @@ RSpec.describe "Internal Project Access" do ...@@ -520,7 +535,8 @@ RSpec.describe "Internal Project Access" do
describe "GET /:project_path/-/environments/new" do describe "GET /:project_path/-/environments/new" do
subject { new_project_environment_path(project) } subject { new_project_environment_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
......
...@@ -18,7 +18,8 @@ RSpec.describe "Private Project Access" do ...@@ -18,7 +18,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path" do describe "GET /:project_path" do
subject { project_path(project) } subject { project_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -32,7 +33,8 @@ RSpec.describe "Private Project Access" do ...@@ -32,7 +33,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/-/tree/master" do describe "GET /:project_path/-/tree/master" do
subject { project_tree_path(project, project.repository.root_ref) } subject { project_tree_path(project, project.repository.root_ref) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -46,7 +48,8 @@ RSpec.describe "Private Project Access" do ...@@ -46,7 +48,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/-/commits/master" do describe "GET /:project_path/-/commits/master" do
subject { project_commits_path(project, project.repository.root_ref, limit: 1) } subject { project_commits_path(project, project.repository.root_ref, limit: 1) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -60,7 +63,8 @@ RSpec.describe "Private Project Access" do ...@@ -60,7 +63,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/-/commit/:sha" do describe "GET /:project_path/-/commit/:sha" do
subject { project_commit_path(project, project.repository.commit) } subject { project_commit_path(project, project.repository.commit) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -74,7 +78,8 @@ RSpec.describe "Private Project Access" do ...@@ -74,7 +78,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/-/compare" do describe "GET /:project_path/-/compare" do
subject { project_compare_index_path(project) } subject { project_compare_index_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -88,7 +93,8 @@ RSpec.describe "Private Project Access" do ...@@ -88,7 +93,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/-/project_members" do describe "GET /:project_path/-/project_members" do
subject { project_project_members_path(project) } subject { project_project_members_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -102,7 +108,8 @@ RSpec.describe "Private Project Access" do ...@@ -102,7 +108,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/-/settings/ci_cd" do describe "GET /:project_path/-/settings/ci_cd" do
subject { project_settings_ci_cd_path(project) } subject { project_settings_ci_cd_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -116,7 +123,8 @@ RSpec.describe "Private Project Access" do ...@@ -116,7 +123,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/-/settings/repository" do describe "GET /:project_path/-/settings/repository" do
subject { project_settings_repository_path(project) } subject { project_settings_repository_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -132,7 +140,8 @@ RSpec.describe "Private Project Access" do ...@@ -132,7 +140,8 @@ RSpec.describe "Private Project Access" do
subject { project_blob_path(project, File.join(commit.id, '.gitignore')) } subject { project_blob_path(project, File.join(commit.id, '.gitignore')) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -146,7 +155,8 @@ RSpec.describe "Private Project Access" do ...@@ -146,7 +155,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/edit" do describe "GET /:project_path/edit" do
subject { edit_project_path(project) } subject { edit_project_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -160,7 +170,8 @@ RSpec.describe "Private Project Access" do ...@@ -160,7 +170,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/deploy_keys" do describe "GET /:project_path/deploy_keys" do
subject { project_deploy_keys_path(project) } subject { project_deploy_keys_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -174,7 +185,8 @@ RSpec.describe "Private Project Access" do ...@@ -174,7 +185,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/issues" do describe "GET /:project_path/issues" do
subject { project_issues_path(project) } subject { project_issues_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -190,7 +202,8 @@ RSpec.describe "Private Project Access" do ...@@ -190,7 +202,8 @@ RSpec.describe "Private Project Access" do
subject { edit_project_issue_path(project, issue) } subject { edit_project_issue_path(project, issue) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -204,7 +217,8 @@ RSpec.describe "Private Project Access" do ...@@ -204,7 +217,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/snippets" do describe "GET /:project_path/snippets" do
subject { project_snippets_path(project) } subject { project_snippets_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -218,7 +232,8 @@ RSpec.describe "Private Project Access" do ...@@ -218,7 +232,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/-/merge_requests" do describe "GET /:project_path/-/merge_requests" do
subject { project_merge_requests_path(project) } subject { project_merge_requests_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -239,7 +254,8 @@ RSpec.describe "Private Project Access" do ...@@ -239,7 +254,8 @@ RSpec.describe "Private Project Access" do
end end
end end
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -260,7 +276,8 @@ RSpec.describe "Private Project Access" do ...@@ -260,7 +276,8 @@ RSpec.describe "Private Project Access" do
end end
end end
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -274,7 +291,8 @@ RSpec.describe "Private Project Access" do ...@@ -274,7 +291,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/-/settings/integrations" do describe "GET /:project_path/-/settings/integrations" do
subject { project_settings_integrations_path(project) } subject { project_settings_integrations_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -288,7 +306,8 @@ RSpec.describe "Private Project Access" do ...@@ -288,7 +306,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/pipelines" do describe "GET /:project_path/pipelines" do
subject { project_pipelines_path(project) } subject { project_pipelines_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -316,7 +335,8 @@ RSpec.describe "Private Project Access" do ...@@ -316,7 +335,8 @@ RSpec.describe "Private Project Access" do
subject { project_pipeline_path(project, pipeline) } subject { project_pipeline_path(project, pipeline) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -342,7 +362,8 @@ RSpec.describe "Private Project Access" do ...@@ -342,7 +362,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/builds" do describe "GET /:project_path/builds" do
subject { project_jobs_path(project) } subject { project_jobs_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -371,7 +392,8 @@ RSpec.describe "Private Project Access" do ...@@ -371,7 +392,8 @@ RSpec.describe "Private Project Access" do
subject { project_job_path(project, build.id) } subject { project_job_path(project, build.id) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -405,7 +427,8 @@ RSpec.describe "Private Project Access" do ...@@ -405,7 +427,8 @@ RSpec.describe "Private Project Access" do
subject { trace_project_job_path(project, build.id) } subject { trace_project_job_path(project, build.id) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -435,7 +458,8 @@ RSpec.describe "Private Project Access" do ...@@ -435,7 +458,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/-/environments" do describe "GET /:project_path/-/environments" do
subject { project_environments_path(project) } subject { project_environments_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -451,7 +475,8 @@ RSpec.describe "Private Project Access" do ...@@ -451,7 +475,8 @@ RSpec.describe "Private Project Access" do
subject { project_environment_path(project, environment) } subject { project_environment_path(project, environment) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -467,7 +492,8 @@ RSpec.describe "Private Project Access" do ...@@ -467,7 +492,8 @@ RSpec.describe "Private Project Access" do
subject { project_environment_deployments_path(project, environment) } subject { project_environment_deployments_path(project, environment) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -481,7 +507,8 @@ RSpec.describe "Private Project Access" do ...@@ -481,7 +507,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/-/environments/new" do describe "GET /:project_path/-/environments/new" do
subject { new_project_environment_path(project) } subject { new_project_environment_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -495,7 +522,8 @@ RSpec.describe "Private Project Access" do ...@@ -495,7 +522,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/pipeline_schedules" do describe "GET /:project_path/pipeline_schedules" do
subject { project_pipeline_schedules_path(project) } subject { project_pipeline_schedules_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -509,7 +537,8 @@ RSpec.describe "Private Project Access" do ...@@ -509,7 +537,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/pipeline_schedules/new" do describe "GET /:project_path/pipeline_schedules/new" do
subject { new_project_pipeline_schedule_path(project) } subject { new_project_pipeline_schedule_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -523,7 +552,8 @@ RSpec.describe "Private Project Access" do ...@@ -523,7 +552,8 @@ RSpec.describe "Private Project Access" do
describe "GET /:project_path/-/environments/new" do describe "GET /:project_path/-/environments/new" do
subject { new_project_pipeline_schedule_path(project) } subject { new_project_pipeline_schedule_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -545,7 +575,8 @@ RSpec.describe "Private Project Access" do ...@@ -545,7 +575,8 @@ RSpec.describe "Private Project Access" do
subject { project_container_registry_index_path(project) } subject { project_container_registry_index_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
......
...@@ -102,7 +102,8 @@ RSpec.describe "Public Project Access" do ...@@ -102,7 +102,8 @@ RSpec.describe "Public Project Access" do
describe "GET /:project_path/-/settings/ci_cd" do describe "GET /:project_path/-/settings/ci_cd" do
subject { project_settings_ci_cd_path(project) } subject { project_settings_ci_cd_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -116,7 +117,8 @@ RSpec.describe "Public Project Access" do ...@@ -116,7 +117,8 @@ RSpec.describe "Public Project Access" do
describe "GET /:project_path/-/settings/repository" do describe "GET /:project_path/-/settings/repository" do
subject { project_settings_repository_path(project) } subject { project_settings_repository_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -181,7 +183,8 @@ RSpec.describe "Public Project Access" do ...@@ -181,7 +183,8 @@ RSpec.describe "Public Project Access" do
project.update(public_builds: false) project.update(public_builds: false)
end end
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -220,7 +223,8 @@ RSpec.describe "Public Project Access" do ...@@ -220,7 +223,8 @@ RSpec.describe "Public Project Access" do
project.update(public_builds: false) project.update(public_builds: false)
end end
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -259,7 +263,8 @@ RSpec.describe "Public Project Access" do ...@@ -259,7 +263,8 @@ RSpec.describe "Public Project Access" do
project.update(public_builds: false) project.update(public_builds: false)
end end
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -274,7 +279,8 @@ RSpec.describe "Public Project Access" do ...@@ -274,7 +279,8 @@ RSpec.describe "Public Project Access" do
describe "GET /:project_path/pipeline_schedules" do describe "GET /:project_path/pipeline_schedules" do
subject { project_pipeline_schedules_path(project) } subject { project_pipeline_schedules_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is allowed for admin when admin mode is disabled') { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -288,7 +294,8 @@ RSpec.describe "Public Project Access" do ...@@ -288,7 +294,8 @@ RSpec.describe "Public Project Access" do
describe "GET /:project_path/-/environments" do describe "GET /:project_path/-/environments" do
subject { project_environments_path(project) } subject { project_environments_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is allowed for admin when admin mode is disabled') { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -304,7 +311,8 @@ RSpec.describe "Public Project Access" do ...@@ -304,7 +311,8 @@ RSpec.describe "Public Project Access" do
subject { project_environment_path(project, environment) } subject { project_environment_path(project, environment) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is allowed for admin when admin mode is disabled') { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -320,7 +328,8 @@ RSpec.describe "Public Project Access" do ...@@ -320,7 +328,8 @@ RSpec.describe "Public Project Access" do
subject { project_environment_deployments_path(project, environment) } subject { project_environment_deployments_path(project, environment) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is allowed for admin when admin mode is disabled') { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -334,7 +343,8 @@ RSpec.describe "Public Project Access" do ...@@ -334,7 +343,8 @@ RSpec.describe "Public Project Access" do
describe "GET /:project_path/-/environments/new" do describe "GET /:project_path/-/environments/new" do
subject { new_project_environment_path(project) } subject { new_project_environment_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -363,7 +373,8 @@ RSpec.describe "Public Project Access" do ...@@ -363,7 +373,8 @@ RSpec.describe "Public Project Access" do
describe "GET /:project_path/edit" do describe "GET /:project_path/edit" do
subject { edit_project_path(project) } subject { edit_project_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -377,7 +388,8 @@ RSpec.describe "Public Project Access" do ...@@ -377,7 +388,8 @@ RSpec.describe "Public Project Access" do
describe "GET /:project_path/deploy_keys" do describe "GET /:project_path/deploy_keys" do
subject { project_deploy_keys_path(project) } subject { project_deploy_keys_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
...@@ -407,7 +419,8 @@ RSpec.describe "Public Project Access" do ...@@ -407,7 +419,8 @@ RSpec.describe "Public Project Access" do
subject { edit_project_issue_path(project, issue) } subject { edit_project_issue_path(project, issue) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -435,7 +448,8 @@ RSpec.describe "Public Project Access" do ...@@ -435,7 +448,8 @@ RSpec.describe "Public Project Access" do
describe "GET /:project_path/snippets/new" do describe "GET /:project_path/snippets/new" do
subject { new_project_snippet_path(project) } subject { new_project_snippet_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -463,7 +477,8 @@ RSpec.describe "Public Project Access" do ...@@ -463,7 +477,8 @@ RSpec.describe "Public Project Access" do
describe "GET /:project_path/-/merge_requests/new" do describe "GET /:project_path/-/merge_requests/new" do
subject { project_new_merge_request_path(project) } subject { project_new_merge_request_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -519,7 +534,8 @@ RSpec.describe "Public Project Access" do ...@@ -519,7 +534,8 @@ RSpec.describe "Public Project Access" do
describe "GET /:project_path/-/settings/integrations" do describe "GET /:project_path/-/settings/integrations" do
subject { project_settings_integrations_path(project) } subject { project_settings_integrations_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_denied_for(:developer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) }
......
...@@ -26,7 +26,8 @@ RSpec.describe "Internal Project Snippets Access" do ...@@ -26,7 +26,8 @@ RSpec.describe "Internal Project Snippets Access" do
describe "GET /:project_path/snippets/new" do describe "GET /:project_path/snippets/new" do
subject { new_project_snippet_path(project) } subject { new_project_snippet_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -55,7 +56,8 @@ RSpec.describe "Internal Project Snippets Access" do ...@@ -55,7 +56,8 @@ RSpec.describe "Internal Project Snippets Access" do
context "for a private snippet" do context "for a private snippet" do
subject { project_snippet_path(project, private_snippet) } subject { project_snippet_path(project, private_snippet) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -85,7 +87,8 @@ RSpec.describe "Internal Project Snippets Access" do ...@@ -85,7 +87,8 @@ RSpec.describe "Internal Project Snippets Access" do
context "for a private snippet" do context "for a private snippet" do
subject { raw_project_snippet_path(project, private_snippet) } subject { raw_project_snippet_path(project, private_snippet) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
......
...@@ -12,7 +12,8 @@ RSpec.describe "Private Project Snippets Access" do ...@@ -12,7 +12,8 @@ RSpec.describe "Private Project Snippets Access" do
describe "GET /:project_path/snippets" do describe "GET /:project_path/snippets" do
subject { project_snippets_path(project) } subject { project_snippets_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -26,7 +27,8 @@ RSpec.describe "Private Project Snippets Access" do ...@@ -26,7 +27,8 @@ RSpec.describe "Private Project Snippets Access" do
describe "GET /:project_path/snippets/new" do describe "GET /:project_path/snippets/new" do
subject { new_project_snippet_path(project) } subject { new_project_snippet_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -40,7 +42,8 @@ RSpec.describe "Private Project Snippets Access" do ...@@ -40,7 +42,8 @@ RSpec.describe "Private Project Snippets Access" do
describe "GET /:project_path/snippets/:id for a private snippet" do describe "GET /:project_path/snippets/:id for a private snippet" do
subject { project_snippet_path(project, private_snippet) } subject { project_snippet_path(project, private_snippet) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -54,7 +57,8 @@ RSpec.describe "Private Project Snippets Access" do ...@@ -54,7 +57,8 @@ RSpec.describe "Private Project Snippets Access" do
describe "GET /:project_path/snippets/:id/raw for a private snippet" do describe "GET /:project_path/snippets/:id/raw for a private snippet" do
subject { raw_project_snippet_path(project, private_snippet) } subject { raw_project_snippet_path(project, private_snippet) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
......
...@@ -27,7 +27,8 @@ RSpec.describe "Public Project Snippets Access" do ...@@ -27,7 +27,8 @@ RSpec.describe "Public Project Snippets Access" do
describe "GET /:project_path/snippets/new" do describe "GET /:project_path/snippets/new" do
subject { new_project_snippet_path(project) } subject { new_project_snippet_path(project) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -70,7 +71,8 @@ RSpec.describe "Public Project Snippets Access" do ...@@ -70,7 +71,8 @@ RSpec.describe "Public Project Snippets Access" do
context "for a private snippet" do context "for a private snippet" do
subject { project_snippet_path(project, private_snippet) } subject { project_snippet_path(project, private_snippet) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
...@@ -114,7 +116,8 @@ RSpec.describe "Public Project Snippets Access" do ...@@ -114,7 +116,8 @@ RSpec.describe "Public Project Snippets Access" do
context "for a private snippet" do context "for a private snippet" do
subject { raw_project_snippet_path(project, private_snippet) } subject { raw_project_snippet_path(project, private_snippet) }
it { is_expected.to be_allowed_for(:admin) } it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { is_expected.to be_allowed_for(:admin) }
it('is denied for admin when admin mode is disabled') { is_expected.to be_denied_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) }
it { is_expected.to be_allowed_for(:developer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) }
......
...@@ -19,6 +19,7 @@ RSpec.describe 'Usage stats consent' do ...@@ -19,6 +19,7 @@ RSpec.describe 'Usage stats consent' do
end end
gitlab_sign_in(user) gitlab_sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
end end
it 'hides the banner permanently when sets usage stats' do it 'hides the banner permanently when sets usage stats' do
......
...@@ -278,24 +278,18 @@ RSpec.configure do |config| ...@@ -278,24 +278,18 @@ RSpec.configure do |config|
# context 'some test in mocked dir', :do_not_mock_admin_mode do ... end # context 'some test in mocked dir', :do_not_mock_admin_mode do ... end
admin_mode_mock_dirs = %w( admin_mode_mock_dirs = %w(
./ee/spec/elastic_integration ./ee/spec/elastic_integration
./ee/spec/features
./ee/spec/finders ./ee/spec/finders
./ee/spec/lib ./ee/spec/lib
./ee/spec/requests/admin ./ee/spec/requests/admin
./ee/spec/serializers ./ee/spec/serializers
./ee/spec/support/protected_tags
./ee/spec/support/shared_examples/features
./ee/spec/support/shared_examples/finders/geo ./ee/spec/support/shared_examples/finders/geo
./ee/spec/support/shared_examples/graphql/geo ./ee/spec/support/shared_examples/graphql/geo
./spec/features
./spec/finders ./spec/finders
./spec/frontend ./spec/frontend
./spec/helpers ./spec/helpers
./spec/lib ./spec/lib
./spec/requests ./spec/requests
./spec/serializers ./spec/serializers
./spec/support/protected_tags
./spec/support/shared_examples/features
./spec/support/shared_examples/requests ./spec/support/shared_examples/requests
./spec/support/shared_examples/lib/gitlab ./spec/support/shared_examples/lib/gitlab
./spec/views ./spec/views
......
...@@ -52,7 +52,7 @@ module AccessMatchers ...@@ -52,7 +52,7 @@ module AccessMatchers
emulate_user(user, @membership) emulate_user(user, @membership)
visit(url) visit(url)
status_code == 200 && current_path != new_user_session_path status_code == 200 && !current_path.in?([new_user_session_path, new_admin_session_path])
end end
chain :of do |membership| chain :of do |membership|
...@@ -67,7 +67,7 @@ module AccessMatchers ...@@ -67,7 +67,7 @@ module AccessMatchers
emulate_user(user, @membership) emulate_user(user, @membership)
visit(url) visit(url)
[401, 404].include?(status_code) || current_path == new_user_session_path [401, 404].include?(status_code) || current_path.in?([new_user_session_path, new_admin_session_path])
end end
chain :of do |membership| chain :of do |membership|
......
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