diff options
Diffstat (limited to 'spec/features')
85 files changed, 662 insertions, 309 deletions
diff --git a/spec/features/admin/admin_abuse_reports_spec.rb b/spec/features/admin/admin_abuse_reports_spec.rb index 845e186dd5b..192182adddc 100644 --- a/spec/features/admin/admin_abuse_reports_spec.rb +++ b/spec/features/admin/admin_abuse_reports_spec.rb @@ -7,7 +7,9 @@ RSpec.describe "Admin::AbuseReports", :js do context 'as an admin' do before do - sign_in(create(:admin)) + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end describe 'if a user has been reported for abuse' do diff --git a/spec/features/admin/admin_appearance_spec.rb b/spec/features/admin/admin_appearance_spec.rb index 48aaec6e6df..67a8d6ec601 100644 --- a/spec/features/admin/admin_appearance_spec.rb +++ b/spec/features/admin/admin_appearance_spec.rb @@ -4,9 +4,11 @@ require 'spec_helper' RSpec.describe 'Admin Appearance' do let!(:appearance) { create(:appearance) } + let(:admin) { create(:admin) } it 'Create new appearance' do - sign_in(create(:admin)) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) visit admin_appearances_path fill_in 'appearance_title', with: 'MyCompany' @@ -26,7 +28,8 @@ RSpec.describe 'Admin Appearance' do end 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 click_link "Sign-in page" @@ -35,7 +38,8 @@ RSpec.describe 'Admin Appearance' do end 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 click_link "New project page" @@ -45,7 +49,8 @@ RSpec.describe 'Admin Appearance' do context 'Custom system header and footer' do before do - sign_in(create(:admin)) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end context 'when system header and footer messages are empty' do @@ -82,7 +87,8 @@ RSpec.describe 'Admin Appearance' do end it 'Custom new project page' do - sign_in create(:user) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) visit new_project_path expect_custom_new_project_appearance(appearance) @@ -91,6 +97,7 @@ RSpec.describe 'Admin Appearance' do context 'Profile page with custom profile image guidelines' do before do sign_in(create(:admin)) + gitlab_enable_admin_mode_sign_in(admin) visit admin_appearances_path fill_in 'appearance_profile_image_guidelines', with: 'Custom profile image guidelines, please :smile:!' click_button 'Update appearance settings' @@ -105,7 +112,8 @@ RSpec.describe 'Admin Appearance' do end it 'Appearance logo' do - sign_in(create(:admin)) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) visit admin_appearances_path attach_file(:appearance_logo, logo_fixture) @@ -117,7 +125,8 @@ RSpec.describe 'Admin Appearance' do end it 'Header logos' do - sign_in(create(:admin)) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) visit admin_appearances_path attach_file(:appearance_header_logo, logo_fixture) @@ -129,7 +138,8 @@ RSpec.describe 'Admin Appearance' do end it 'Favicon' do - sign_in(create(:admin)) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) visit admin_appearances_path attach_file(:appearance_favicon, logo_fixture) diff --git a/spec/features/admin/admin_broadcast_messages_spec.rb b/spec/features/admin/admin_broadcast_messages_spec.rb index 091ed0a3396..586785272ae 100644 --- a/spec/features/admin/admin_broadcast_messages_spec.rb +++ b/spec/features/admin/admin_broadcast_messages_spec.rb @@ -4,7 +4,9 @@ require 'spec_helper' RSpec.describe 'Admin Broadcast Messages' 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') visit admin_broadcast_messages_path end diff --git a/spec/features/admin/admin_browse_spam_logs_spec.rb b/spec/features/admin/admin_browse_spam_logs_spec.rb index 65847876c11..9f63c8b5223 100644 --- a/spec/features/admin/admin_browse_spam_logs_spec.rb +++ b/spec/features/admin/admin_browse_spam_logs_spec.rb @@ -6,7 +6,9 @@ RSpec.describe 'Admin browse spam logs' do let!(:spam_log) { create(:spam_log, description: 'abcde ' * 20) } before do - sign_in(create(:admin)) + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end it 'Browse spam logs' do diff --git a/spec/features/admin/admin_builds_spec.rb b/spec/features/admin/admin_builds_spec.rb index 166fde0f37a..42827dd5b49 100644 --- a/spec/features/admin/admin_builds_spec.rb +++ b/spec/features/admin/admin_builds_spec.rb @@ -4,7 +4,9 @@ require 'spec_helper' RSpec.describe 'Admin Builds' do before do - sign_in(create(:admin)) + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end describe 'GET /admin/builds' do diff --git a/spec/features/admin/admin_cohorts_spec.rb b/spec/features/admin/admin_cohorts_spec.rb index f91446ed222..982a9333275 100644 --- a/spec/features/admin/admin_cohorts_spec.rb +++ b/spec/features/admin/admin_cohorts_spec.rb @@ -4,7 +4,9 @@ require 'spec_helper' RSpec.describe 'Cohorts page' do before do - sign_in(create(:admin)) + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end context 'with usage ping enabled' do diff --git a/spec/features/admin/admin_deploy_keys_spec.rb b/spec/features/admin/admin_deploy_keys_spec.rb index 2039a6ff1ee..c326d0fd741 100644 --- a/spec/features/admin/admin_deploy_keys_spec.rb +++ b/spec/features/admin/admin_deploy_keys_spec.rb @@ -7,7 +7,9 @@ RSpec.describe 'admin deploy keys' do let!(:another_deploy_key) { create(:another_deploy_key, public: true) } before do - sign_in(create(:admin)) + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end it 'show all public deploy keys' do diff --git a/spec/features/admin/admin_dev_ops_report_spec.rb b/spec/features/admin/admin_dev_ops_report_spec.rb index 3b2c9d75870..a05fa0640d8 100644 --- a/spec/features/admin/admin_dev_ops_report_spec.rb +++ b/spec/features/admin/admin_dev_ops_report_spec.rb @@ -4,7 +4,9 @@ require 'spec_helper' RSpec.describe 'DevOps Report page', :js do before do - sign_in(create(:admin)) + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end context 'with devops_adoption feature flag disabled' do diff --git a/spec/features/admin/admin_disables_git_access_protocol_spec.rb b/spec/features/admin/admin_disables_git_access_protocol_spec.rb index d7feb21a8b3..f7f0592a315 100644 --- a/spec/features/admin/admin_disables_git_access_protocol_spec.rb +++ b/spec/features/admin/admin_disables_git_access_protocol_spec.rb @@ -12,6 +12,7 @@ RSpec.describe 'Admin disables Git access protocol', :js do before do stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end context 'with HTTP disabled' do diff --git a/spec/features/admin/admin_disables_two_factor_spec.rb b/spec/features/admin/admin_disables_two_factor_spec.rb index 216c8ae36c7..1f34c4ed17c 100644 --- a/spec/features/admin/admin_disables_two_factor_spec.rb +++ b/spec/features/admin/admin_disables_two_factor_spec.rb @@ -4,7 +4,9 @@ require 'spec_helper' RSpec.describe 'Admin disables 2FA for a user' 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) edit_user(user) @@ -19,7 +21,9 @@ RSpec.describe 'Admin disables 2FA for a user' do end 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) edit_user(user) diff --git a/spec/features/admin/admin_groups_spec.rb b/spec/features/admin/admin_groups_spec.rb index 96709cf8a12..c05e90d145e 100644 --- a/spec/features/admin/admin_groups_spec.rb +++ b/spec/features/admin/admin_groups_spec.rb @@ -13,6 +13,7 @@ RSpec.describe 'Admin Groups' do before do sign_in(current_user) + gitlab_enable_admin_mode_sign_in(current_user) stub_application_setting(default_group_visibility: internal) end diff --git a/spec/features/admin/admin_health_check_spec.rb b/spec/features/admin/admin_health_check_spec.rb index dfc7f5f6f84..0f6cba6c105 100644 --- a/spec/features/admin/admin_health_check_spec.rb +++ b/spec/features/admin/admin_health_check_spec.rb @@ -9,6 +9,7 @@ RSpec.describe "Admin Health Check", :feature do before do stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end describe '#show' do diff --git a/spec/features/admin/admin_hook_logs_spec.rb b/spec/features/admin/admin_hook_logs_spec.rb index f4a70621cee..3f63bf9a15c 100644 --- a/spec/features/admin/admin_hook_logs_spec.rb +++ b/spec/features/admin/admin_hook_logs_spec.rb @@ -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') } before do - sign_in(create(:admin)) + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end it 'show list of hook logs' do diff --git a/spec/features/admin/admin_hooks_spec.rb b/spec/features/admin/admin_hooks_spec.rb index 1c14d65a1cd..3fed402267c 100644 --- a/spec/features/admin/admin_hooks_spec.rb +++ b/spec/features/admin/admin_hooks_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Admin::Hooks' do before do sign_in(user) + gitlab_enable_admin_mode_sign_in(user) end describe 'GET /admin/hooks' do diff --git a/spec/features/admin/admin_labels_spec.rb b/spec/features/admin/admin_labels_spec.rb index 35638e0829b..815a73b1450 100644 --- a/spec/features/admin/admin_labels_spec.rb +++ b/spec/features/admin/admin_labels_spec.rb @@ -7,7 +7,9 @@ RSpec.describe 'admin issues labels' do let!(:feature_label) { Label.create(title: 'feature', template: true) } before do - sign_in(create(:admin)) + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end describe 'list' do diff --git a/spec/features/admin/admin_manage_applications_spec.rb b/spec/features/admin/admin_manage_applications_spec.rb index 7a9a6f2ccb8..e54837ede11 100644 --- a/spec/features/admin/admin_manage_applications_spec.rb +++ b/spec/features/admin/admin_manage_applications_spec.rb @@ -4,7 +4,9 @@ require 'spec_helper' RSpec.describe 'admin manage applications' do before do - sign_in(create(:admin)) + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end it 'creates new oauth application' do diff --git a/spec/features/admin/admin_mode/login_spec.rb b/spec/features/admin/admin_mode/login_spec.rb index 7cbba9ec674..f1dee075925 100644 --- a/spec/features/admin/admin_mode/login_spec.rb +++ b/spec/features/admin/admin_mode/login_spec.rb @@ -2,7 +2,7 @@ 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 UserLoginHelper include LdapHelpers diff --git a/spec/features/admin/admin_mode/logout_spec.rb b/spec/features/admin/admin_mode/logout_spec.rb index b4d49fe760f..b7fa59bbfb7 100644 --- a/spec/features/admin/admin_mode/logout_spec.rb +++ b/spec/features/admin/admin_mode/logout_spec.rb @@ -2,7 +2,7 @@ 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 UserLoginHelper diff --git a/spec/features/admin/admin_mode/workers_spec.rb b/spec/features/admin/admin_mode/workers_spec.rb index d037f5555dc..fbbcf19063b 100644 --- a/spec/features/admin/admin_mode/workers_spec.rb +++ b/spec/features/admin/admin_mode/workers_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' # 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_to_delete) { create(:user) } diff --git a/spec/features/admin/admin_mode_spec.rb b/spec/features/admin/admin_mode_spec.rb index 3b4edbc1a07..8169b3a20db 100644 --- a/spec/features/admin/admin_mode_spec.rb +++ b/spec/features/admin/admin_mode_spec.rb @@ -2,7 +2,7 @@ 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 StubENV diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb index 522da760062..ff4e592234b 100644 --- a/spec/features/admin/admin_projects_spec.rb +++ b/spec/features/admin/admin_projects_spec.rb @@ -11,6 +11,7 @@ RSpec.describe "Admin::Projects" do before do sign_in(current_user) + gitlab_enable_admin_mode_sign_in(current_user) end describe "GET /admin/projects" do diff --git a/spec/features/admin/admin_requests_profiles_spec.rb b/spec/features/admin/admin_requests_profiles_spec.rb index c649fdd8e19..e92528d431d 100644 --- a/spec/features/admin/admin_requests_profiles_spec.rb +++ b/spec/features/admin/admin_requests_profiles_spec.rb @@ -7,7 +7,9 @@ RSpec.describe 'Admin::RequestsProfilesController' do before do 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 after do diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb index 0e20ccf6bec..e16cde3fa1c 100644 --- a/spec/features/admin/admin_runners_spec.rb +++ b/spec/features/admin/admin_runners_spec.rb @@ -9,7 +9,9 @@ RSpec.describe "Admin Runners" do before do 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 describe "Runners page" do @@ -282,6 +284,12 @@ RSpec.describe "Admin Runners" do visit admin_runner_path(runner) end + describe 'runner page breadcrumbs' do + it 'contains the current runner’s short sha' do + expect(page.find('h2')).to have_content(runner.short_sha) + end + end + describe 'projects' do it 'contains project names' do expect(page).to have_content(@project1.full_name) diff --git a/spec/features/admin/admin_sees_project_statistics_spec.rb b/spec/features/admin/admin_sees_project_statistics_spec.rb index d94889b825a..be781730924 100644 --- a/spec/features/admin/admin_sees_project_statistics_spec.rb +++ b/spec/features/admin/admin_sees_project_statistics_spec.rb @@ -7,6 +7,7 @@ RSpec.describe "Admin > Admin sees project statistics" do before do sign_in(current_user) + gitlab_enable_admin_mode_sign_in(current_user) visit admin_project_path(project) end @@ -15,7 +16,7 @@ RSpec.describe "Admin > Admin sees project statistics" do let(:project) { create(:project, :repository) } it "shows project statistics" do - expect(page).to have_content("Storage: 0 Bytes (Repository: 0 Bytes / Wikis: 0 Bytes / Build Artifacts: 0 Bytes / LFS: 0 Bytes / Snippets: 0 Bytes)") + expect(page).to have_content("Storage: 0 Bytes (Repository: 0 Bytes / Wikis: 0 Bytes / Build Artifacts: 0 Bytes / LFS: 0 Bytes / Snippets: 0 Bytes / Packages: 0 Bytes / Uploads: 0 Bytes)") end end diff --git a/spec/features/admin/admin_sees_projects_statistics_spec.rb b/spec/features/admin/admin_sees_projects_statistics_spec.rb index 786fa98255c..2e96814d1e9 100644 --- a/spec/features/admin/admin_sees_projects_statistics_spec.rb +++ b/spec/features/admin/admin_sees_projects_statistics_spec.rb @@ -10,6 +10,7 @@ RSpec.describe "Admin > Admin sees projects statistics" do create(:project, :repository) { |project| project.statistics.destroy } sign_in(current_user) + gitlab_enable_admin_mode_sign_in(current_user) visit admin_projects_path end diff --git a/spec/features/admin/admin_serverless_domains_spec.rb b/spec/features/admin/admin_serverless_domains_spec.rb index 256887f425f..fc84df91854 100644 --- a/spec/features/admin/admin_serverless_domains_spec.rb +++ b/spec/features/admin/admin_serverless_domains_spec.rb @@ -7,7 +7,9 @@ RSpec.describe 'Admin Serverless Domains', :js do before do 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 it 'Add domain with certificate' do diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 8929abc7edc..9d1e71092ae 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -2,7 +2,7 @@ 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 TermsHelper include UsageDataHelpers diff --git a/spec/features/admin/admin_system_info_spec.rb b/spec/features/admin/admin_system_info_spec.rb index 6a0448fd890..2225f25aa1e 100644 --- a/spec/features/admin/admin_system_info_spec.rb +++ b/spec/features/admin/admin_system_info_spec.rb @@ -4,7 +4,9 @@ require 'spec_helper' RSpec.describe 'Admin System Info' do before do - sign_in(create(:admin)) + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end describe 'GET /admin/system_info' do diff --git a/spec/features/admin/admin_users_impersonation_tokens_spec.rb b/spec/features/admin/admin_users_impersonation_tokens_spec.rb index ec3dd322f97..cae190e76b0 100644 --- a/spec/features/admin/admin_users_impersonation_tokens_spec.rb +++ b/spec/features/admin/admin_users_impersonation_tokens_spec.rb @@ -20,6 +20,7 @@ RSpec.describe 'Admin > Users > Impersonation Tokens', :js do before do sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end describe "token creation" do diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index 97a30143a59..8809d04e6ec 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -13,6 +13,7 @@ RSpec.describe "Admin::Users" do before do sign_in(current_user) + gitlab_enable_admin_mode_sign_in(current_user) end describe "GET /admin/users" do @@ -205,8 +206,8 @@ RSpec.describe "Admin::Users" do end end - context 'when blocking a user' do - it 'shows confirmation and allows blocking', :js do + context 'when blocking/unblocking a user' do + it 'shows confirmation and allows blocking and unblocking', :js do expect(page).to have_content(user.email) find("[data-testid='user-action-button-#{user.id}']").click @@ -228,6 +229,30 @@ RSpec.describe "Admin::Users" do expect(page).to have_content('Successfully blocked') expect(page).not_to have_content(user.email) + + click_link 'Blocked' + + wait_for_requests + + expect(page).to have_content(user.email) + + find("[data-testid='user-action-button-#{user.id}']").click + + within find("[data-testid='user-action-dropdown-#{user.id}']") do + find('li button', text: 'Unblock').click + end + + wait_for_requests + + expect(page).to have_content('Unblock user') + expect(page).to have_content('You can always block their account again if needed.') + + find('.modal-footer button', text: 'Unblock').click + + wait_for_requests + + expect(page).to have_content('Successfully unblocked') + expect(page).not_to have_content(user.email) end end end @@ -388,8 +413,8 @@ RSpec.describe "Admin::Users" do end end - context 'when blocking the user' do - it 'shows confirmation and allows blocking', :js do + context 'when blocking/unblocking the user' do + it 'shows confirmation and allows blocking and unblocking', :js do visit admin_user_path(user) find('button', text: 'Block user').click @@ -405,6 +430,20 @@ RSpec.describe "Admin::Users" do expect(page).to have_content('Successfully blocked') expect(page).to have_content('This user is blocked') + + find('button', text: 'Unblock user').click + + wait_for_requests + + expect(page).to have_content('Unblock user') + expect(page).to have_content('You can always block their account again if needed.') + + find('.modal-footer button', text: 'Unblock').click + + wait_for_requests + + expect(page).to have_content('Successfully unblocked') + expect(page).to have_content('Block this user') end end diff --git a/spec/features/admin/admin_uses_repository_checks_spec.rb b/spec/features/admin/admin_uses_repository_checks_spec.rb index 0fb5124f673..0e448446085 100644 --- a/spec/features/admin/admin_uses_repository_checks_spec.rb +++ b/spec/features/admin/admin_uses_repository_checks_spec.rb @@ -2,7 +2,7 @@ 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 let(:admin) { create(:admin) } diff --git a/spec/features/admin/clusters/applications_spec.rb b/spec/features/admin/clusters/applications_spec.rb index 3bcadfdbfc1..e083e4fee4c 100644 --- a/spec/features/admin/clusters/applications_spec.rb +++ b/spec/features/admin/clusters/applications_spec.rb @@ -10,6 +10,7 @@ RSpec.describe 'Instance-level Cluster Applications', :js do before do sign_in(user) + gitlab_enable_admin_mode_sign_in(user) end describe 'Installing applications' do diff --git a/spec/features/admin/clusters/eks_spec.rb b/spec/features/admin/clusters/eks_spec.rb index ad7122bf182..a1bac720349 100644 --- a/spec/features/admin/clusters/eks_spec.rb +++ b/spec/features/admin/clusters/eks_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Instance-level AWS EKS Cluster', :js do before do sign_in(user) + gitlab_enable_admin_mode_sign_in(user) end context 'when user does not have a cluster and visits group clusters page' do diff --git a/spec/features/admin/dashboard_spec.rb b/spec/features/admin/dashboard_spec.rb index acb8fb54e11..c040811ada1 100644 --- a/spec/features/admin/dashboard_spec.rb +++ b/spec/features/admin/dashboard_spec.rb @@ -6,7 +6,9 @@ RSpec.describe 'admin visits dashboard' do include ProjectForksHelper before do - sign_in(create(:admin)) + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end context 'counting forks', :js do diff --git a/spec/features/admin/services/admin_activates_prometheus_spec.rb b/spec/features/admin/services/admin_activates_prometheus_spec.rb index 199eae59afc..a225de365c8 100644 --- a/spec/features/admin/services/admin_activates_prometheus_spec.rb +++ b/spec/features/admin/services/admin_activates_prometheus_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Admin activates Prometheus', :js do before do sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) visit(admin_application_settings_services_path) diff --git a/spec/features/admin/services/admin_visits_service_templates_spec.rb b/spec/features/admin/services/admin_visits_service_templates_spec.rb index a37e57304aa..563bca8b32f 100644 --- a/spec/features/admin/services/admin_visits_service_templates_spec.rb +++ b/spec/features/admin/services/admin_visits_service_templates_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Admin visits service templates' do before do sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) visit(admin_application_settings_services_path) end diff --git a/spec/features/alerts_settings/user_views_alerts_settings_spec.rb b/spec/features/alerts_settings/user_views_alerts_settings_spec.rb index 0ded13ae607..698a36d3f76 100644 --- a/spec/features/alerts_settings/user_views_alerts_settings_spec.rb +++ b/spec/features/alerts_settings/user_views_alerts_settings_spec.rb @@ -17,7 +17,7 @@ RSpec.describe 'Alert integrations settings form', :js do end describe 'when viewing alert integrations as a maintainer' do - context 'with feature flag enabled' do + context 'with the default page permissions' do before do visit project_settings_operations_path(project, anchor: 'js-alert-management-settings') wait_for_requests @@ -33,19 +33,6 @@ RSpec.describe 'Alert integrations settings form', :js do expect(page).to have_content('1. Select integration type') end end - - context 'with feature flag disabled' do - before do - stub_feature_flags(http_integrations_list: false) - - visit project_settings_operations_path(project, anchor: 'js-alert-management-settings') - wait_for_requests - end - - it 'shows the old alerts setting form' do - expect(page).to have_content('Webhook URL') - end - end end describe 'when viewing alert integrations as a developer' do diff --git a/spec/features/boards/keyboard_shortcut_spec.rb b/spec/features/boards/keyboard_shortcut_spec.rb index f51b4d21e3b..cefb486349d 100644 --- a/spec/features/boards/keyboard_shortcut_spec.rb +++ b/spec/features/boards/keyboard_shortcut_spec.rb @@ -9,7 +9,9 @@ RSpec.describe 'Issue Boards shortcut', :js do before do 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) end @@ -26,7 +28,9 @@ RSpec.describe 'Issue Boards shortcut', :js do let(:project) { create(:project, :issues_disabled) } before do - sign_in(create(:admin)) + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) visit project_path(project) end diff --git a/spec/features/breadcrumbs_schema_markup_spec.rb b/spec/features/breadcrumbs_schema_markup_spec.rb index 30d5f40fea8..a87a3d284de 100644 --- a/spec/features/breadcrumbs_schema_markup_spec.rb +++ b/spec/features/breadcrumbs_schema_markup_spec.rb @@ -15,15 +15,12 @@ RSpec.describe 'Breadcrumbs schema markup', :aggregate_failures do item_list = get_schema_content - expect(item_list.size).to eq 3 + expect(item_list.size).to eq 2 expect(item_list[0]['name']).to eq project.namespace.name expect(item_list[0]['item']).to eq user_url(project.owner) expect(item_list[1]['name']).to eq project.name expect(item_list[1]['item']).to eq project_url(project) - - expect(item_list[2]['name']).to eq 'Details' - expect(item_list[2]['item']).to eq project_url(project) end it 'generates the breadcrumb schema for group projects' do @@ -31,7 +28,7 @@ RSpec.describe 'Breadcrumbs schema markup', :aggregate_failures do item_list = get_schema_content - expect(item_list.size).to eq 4 + expect(item_list.size).to eq 3 expect(item_list[0]['name']).to eq group.name expect(item_list[0]['item']).to eq group_url(group) @@ -40,9 +37,6 @@ RSpec.describe 'Breadcrumbs schema markup', :aggregate_failures do expect(item_list[2]['name']).to eq group_project.name expect(item_list[2]['item']).to eq project_url(group_project) - - expect(item_list[3]['name']).to eq 'Details' - expect(item_list[3]['item']).to eq project_url(group_project) end it 'generates the breadcrumb schema for group' do @@ -50,15 +44,12 @@ RSpec.describe 'Breadcrumbs schema markup', :aggregate_failures do item_list = get_schema_content - expect(item_list.size).to eq 3 + expect(item_list.size).to eq 2 expect(item_list[0]['name']).to eq group.name expect(item_list[0]['item']).to eq group_url(group) expect(item_list[1]['name']).to eq subgroup.name expect(item_list[1]['item']).to eq group_url(subgroup) - - expect(item_list[2]['name']).to eq 'Details' - expect(item_list[2]['item']).to eq group_url(subgroup) end it 'generates the breadcrumb schema for issues' do diff --git a/spec/features/clusters/cluster_detail_page_spec.rb b/spec/features/clusters/cluster_detail_page_spec.rb index 31d6bcda9e8..6fe6c099d80 100644 --- a/spec/features/clusters/cluster_detail_page_spec.rb +++ b/spec/features/clusters/cluster_detail_page_spec.rb @@ -168,6 +168,10 @@ RSpec.describe 'Clusterable > Show page' do let(:cluster_path) { admin_cluster_path(cluster) } 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 let(:cluster_type_label) { 'Instance cluster' } end diff --git a/spec/features/dashboard/merge_requests_spec.rb b/spec/features/dashboard/merge_requests_spec.rb index 952a78ec79a..0237bbc793b 100644 --- a/spec/features/dashboard/merge_requests_spec.rb +++ b/spec/features/dashboard/merge_requests_spec.rb @@ -52,20 +52,29 @@ RSpec.describe 'Dashboard Merge Requests' do end context 'merge requests exist' do + let_it_be(:author_user) { create(:user) } let(:label) { create(:label) } let!(:assigned_merge_request) do create(:merge_request, assignees: [current_user], source_project: project, - author: create(:user)) + author: author_user) + end + + let!(:review_requested_merge_request) do + create(:merge_request, + reviewers: [current_user], + source_branch: 'review', + source_project: project, + author: author_user) end let!(:assigned_merge_request_from_fork) do create(:merge_request, source_branch: 'markdown', assignees: [current_user], target_project: public_project, source_project: forked_project, - author: create(:user)) + author: author_user) end let!(:authored_merge_request) do @@ -94,7 +103,7 @@ RSpec.describe 'Dashboard Merge Requests' do create(:merge_request, source_branch: 'fix', source_project: project, - author: create(:user)) + author: author_user) end before do @@ -111,6 +120,10 @@ RSpec.describe 'Dashboard Merge Requests' do expect(page).not_to have_content(labeled_merge_request.title) end + it 'does not show review requested merge requests' do + expect(page).not_to have_content(review_requested_merge_request.title) + end + it 'shows authored merge requests', :js do reset_filters input_filtered_search("author:=#{current_user.to_reference}") diff --git a/spec/features/expand_collapse_diffs_spec.rb b/spec/features/expand_collapse_diffs_spec.rb index 0912df22924..55bdf4c244e 100644 --- a/spec/features/expand_collapse_diffs_spec.rb +++ b/spec/features/expand_collapse_diffs_spec.rb @@ -10,7 +10,9 @@ RSpec.describe 'Expand and collapse diffs', :js do stub_feature_flags(increased_diff_limits: false) 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 project.repository.copy_gitattributes(branch) diff --git a/spec/features/file_uploads/git_lfs_spec.rb b/spec/features/file_uploads/git_lfs_spec.rb index b902d7ab702..3824c04ada5 100644 --- a/spec/features/file_uploads/git_lfs_spec.rb +++ b/spec/features/file_uploads/git_lfs_spec.rb @@ -6,7 +6,7 @@ RSpec.describe 'Upload a git lfs object', :js do include_context 'file upload requests helpers' 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(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif') } diff --git a/spec/features/groups/show_spec.rb b/spec/features/groups/show_spec.rb index 97732374eb9..3a42fd508b4 100644 --- a/spec/features/groups/show_spec.rb +++ b/spec/features/groups/show_spec.rb @@ -193,4 +193,69 @@ RSpec.describe 'Group show page' do it_behaves_like 'page meta description', 'Lorem ipsum dolor sit amet' end + + context 'structured schema markup' do + let_it_be(:group) { create(:group, :public, :with_avatar, description: 'foo') } + let_it_be(:subgroup) { create(:group, :public, :with_avatar, parent: group, description: 'bar') } + let_it_be_with_reload(:project) { create(:project, :public, :with_avatar, namespace: group, description: 'foo') } + let_it_be(:subproject) { create(:project, :public, :with_avatar, namespace: subgroup, description: 'bar') } + + it 'shows Organization structured markup', :js do + visit path + wait_for_all_requests + + aggregate_failures do + expect(page).to have_selector('.content[itemscope][itemtype="https://schema.org/Organization"]') + + page.within('.group-home-panel') do + expect(page).to have_selector('img.avatar[itemprop="logo"]') + expect(page).to have_selector('[itemprop="name"]', text: group.name) + expect(page).to have_selector('[itemprop="description"]', text: group.description) + end + + page.within('[itemprop="owns"][itemtype="https://schema.org/SoftwareSourceCode"]') do + expect(page).to have_selector('img.avatar[itemprop="image"]') + expect(page).to have_selector('[itemprop="name"]', text: project.name) + expect(page).to have_selector('[itemprop="description"]', text: project.description) + end + + # Finding the subgroup row and expanding it + el = find('[itemprop="subOrganization"][itemtype="https://schema.org/Organization"]') + el.click + wait_for_all_requests + page.within(el) do + expect(page).to have_selector('img.avatar[itemprop="logo"]') + expect(page).to have_selector('[itemprop="name"]', text: subgroup.name) + expect(page).to have_selector('[itemprop="description"]', text: subgroup.description) + + page.within('[itemprop="owns"][itemtype="https://schema.org/SoftwareSourceCode"]') do + expect(page).to have_selector('img.avatar[itemprop="image"]') + expect(page).to have_selector('[itemprop="name"]', text: subproject.name) + expect(page).to have_selector('[itemprop="description"]', text: subproject.description) + end + end + end + end + + it 'does not include structured markup in shared projects tab', :js do + other_project = create(:project, :public) + other_project.project_group_links.create!(group: group) + + visit group_shared_path(group) + wait_for_all_requests + + expect(page).to have_selector('li.group-row') + expect(page).not_to have_selector('[itemprop="owns"][itemtype="https://schema.org/SoftwareSourceCode"]') + end + + it 'does not include structured markup in archived projects tab', :js do + project.update!(archived: true) + + visit group_archived_path(group) + wait_for_all_requests + + expect(page).to have_selector('li.group-row') + expect(page).not_to have_selector('[itemprop="owns"][itemtype="https://schema.org/SoftwareSourceCode"]') + end + end end diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb index b9fd3a1a5cc..0dfa177fcf8 100644 --- a/spec/features/groups_spec.rb +++ b/spec/features/groups_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Group' do - let(:user) { create(:admin) } + let(:user) { create(:user) } before do sign_in(user) @@ -21,8 +21,6 @@ RSpec.describe 'Group' do end describe 'as a non-admin' do - let(:user) { create(:user) } - it 'creates a group and persists visibility radio selection', :js do stub_application_setting(default_group_visibility: :private) @@ -140,6 +138,8 @@ RSpec.describe 'Group' do let(:group) { create(:group, path: 'foo') } context 'as admin' do + let(:user) { create(:admin) } + before do visit new_group_path(group, parent_id: group.id) end @@ -190,6 +190,8 @@ RSpec.describe 'Group' do let(:new_name) { 'new-name' } before do + group.add_owner(user) + visit path end @@ -200,6 +202,8 @@ RSpec.describe 'Group' do it 'saves new settings' 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 click_button 'Save changes' end @@ -229,6 +233,10 @@ RSpec.describe 'Group' do let(:group) { create(:group) } let(:path) { group_path(group) } + before do + group.add_owner(user) + end + it 'parses Markdown' do group.update_attribute(:description, 'This is **my** group') @@ -267,6 +275,10 @@ RSpec.describe 'Group' do let!(:nested_group) { create(:group, parent: group) } let!(:project) { create(:project, namespace: group) } + before do + group.add_owner(user) + end + it 'renders projects and groups on the page' do visit group_path(group) wait_for_requests @@ -294,6 +306,10 @@ RSpec.describe 'Group' 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) } + before do + group.add_owner(user) + end + context 'when user has subgroup creation permissions but not project creation permissions' do it 'only displays "New subgroup" button' do visit group_path(group) diff --git a/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb b/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb index b449939a70c..841727d6120 100644 --- a/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb +++ b/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb @@ -31,7 +31,8 @@ RSpec.describe 'Resolve an open thread in a merge request by creating an issue', visit project_merge_request_path(project, merge_request) end - it 'does not show a link to create a new issue' do + # https://gitlab.com/gitlab-org/gitlab/-/issues/285453 + xit 'does not show a link to create a new issue' do expect(page).not_to have_css resolve_discussion_selector end end diff --git a/spec/features/issues/keyboard_shortcut_spec.rb b/spec/features/issues/keyboard_shortcut_spec.rb index ab40f124257..502412bab5d 100644 --- a/spec/features/issues/keyboard_shortcut_spec.rb +++ b/spec/features/issues/keyboard_shortcut_spec.rb @@ -8,7 +8,7 @@ RSpec.describe 'Issues shortcut', :js do let(:project) { create(:project) } before do - sign_in(create(:admin)) + sign_in(project.owner) visit project_path(project) end @@ -23,7 +23,7 @@ RSpec.describe 'Issues shortcut', :js do let(:project) { create(:project, :issues_disabled) } before do - sign_in(create(:admin)) + sign_in(project.owner) visit project_path(project) end diff --git a/spec/features/issues/user_edits_issue_spec.rb b/spec/features/issues/user_edits_issue_spec.rb index 11b905735de..9d4a6cdb522 100644 --- a/spec/features/issues/user_edits_issue_spec.rb +++ b/spec/features/issues/user_edits_issue_spec.rb @@ -22,6 +22,7 @@ RSpec.describe "Issues > User edits issue", :js do context "from edit page" do before do + stub_licensed_features(multiple_issue_assignees: false) visit edit_project_issue_path(project, issue) end diff --git a/spec/features/markdown/copy_as_gfm_spec.rb b/spec/features/markdown/copy_as_gfm_spec.rb index fbf4e531db1..c9dc764f93b 100644 --- a/spec/features/markdown/copy_as_gfm_spec.rb +++ b/spec/features/markdown/copy_as_gfm_spec.rb @@ -7,10 +7,6 @@ RSpec.describe 'Copy as GFM', :js do include RepoHelpers include ActionView::Helpers::JavaScriptHelper - before do - sign_in(create(:admin)) - end - describe 'Copying rendered GFM' do before do @feat = MarkdownFeature.new @@ -18,6 +14,9 @@ RSpec.describe 'Copy as GFM', :js do # `markdown` helper expects a `@project` variable @project = @feat.project + user = create(:user) + @project.add_maintainer(user) + sign_in(user) visit project_issue_path(@project, @feat.issue) end @@ -650,6 +649,10 @@ RSpec.describe 'Copy as GFM', :js do describe 'Copying code' do let(:project) { create(:project, :repository) } + before do + sign_in(project.owner) + end + context 'from a diff' do shared_examples 'copying code from a diff' do context 'selecting one word of text' do diff --git a/spec/features/merge_request/user_comments_on_diff_spec.rb b/spec/features/merge_request/user_comments_on_diff_spec.rb index c452408cff2..2cb2ee7f6f2 100644 --- a/spec/features/merge_request/user_comments_on_diff_spec.rb +++ b/spec/features/merge_request/user_comments_on_diff_spec.rb @@ -136,7 +136,7 @@ RSpec.describe 'User comments on a diff', :js do add_comment('-13', '+15') end - it 'allows comments on previously hidden lines at the top of a file' do + it 'allows comments on previously hidden lines at the top of a file', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/285294' do # Click -9, expand up, select 1 add and verify comment page.within('[data-path="files/ruby/popen.rb"]') do all('.js-unfold-all')[0].click diff --git a/spec/features/merge_request/user_resolves_conflicts_spec.rb b/spec/features/merge_request/user_resolves_conflicts_spec.rb index 06405232462..1b1152897fc 100644 --- a/spec/features/merge_request/user_resolves_conflicts_spec.rb +++ b/spec/features/merge_request/user_resolves_conflicts_spec.rb @@ -8,11 +8,6 @@ RSpec.describe 'Merge request > User resolves conflicts', :js do let(:project) { create(:project, :repository) } let(:user) { project.creator } - before do - # In order to have the diffs collapsed, we need to disable the increase feature - stub_feature_flags(gitlab_git_diff_size_limit_increase: false) - end - def create_merge_request(source_branch) create(:merge_request, source_branch: source_branch, target_branch: 'conflict-start', source_project: project, merge_status: :unchecked) do |mr| mr.mark_as_unmergeable diff --git a/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb b/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb index e47f9ff2660..38546fd629d 100644 --- a/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb +++ b/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb @@ -18,8 +18,8 @@ RSpec.describe 'Merge request > User sees check out branch modal', :js do expect(page).to have_content('Check out, review, and merge locally') end - it 'closes the check out branch modal with escape keypress' do - find('#modal_merge_info').send_keys(:escape) + it 'closes the check out branch modal with the close action' do + find('.modal button[aria-label="Close"]').click expect(page).not_to have_content('Check out, review, and merge locally') end diff --git a/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb b/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb index 7b319f6aff8..6647a4e9291 100644 --- a/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb +++ b/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb @@ -27,7 +27,6 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', before do stub_application_setting(auto_devops_enabled: false) - stub_feature_flags(ci_merge_request_pipeline: true) stub_ci_pipeline_yaml_file(YAML.dump(config)) project.add_maintainer(user) sign_in(user) diff --git a/spec/features/profiles/account_spec.rb b/spec/features/profiles/account_spec.rb index 62d8a96c1b2..2e8d9ef80cd 100644 --- a/spec/features/profiles/account_spec.rb +++ b/spec/features/profiles/account_spec.rb @@ -78,14 +78,14 @@ RSpec.describe 'Profile > Account', :js do update_username(new_username) visit new_project_path expect(current_path).to eq(new_project_path) - expect(find('.breadcrumbs-sub-title')).to have_content('Details') + expect(find('.breadcrumbs')).to have_content(user.name) end it 'the old project path redirects to the new path' do update_username(new_username) visit old_project_path expect(current_path).to eq(new_project_path) - expect(find('.breadcrumbs-sub-title')).to have_content('Details') + expect(find('.breadcrumbs')).to have_content(user.name) end end end diff --git a/spec/features/profiles/active_sessions_spec.rb b/spec/features/profiles/active_sessions_spec.rb index 75531d43df2..ff969a7786d 100644 --- a/spec/features/profiles/active_sessions_spec.rb +++ b/spec/features/profiles/active_sessions_spec.rb @@ -45,6 +45,7 @@ RSpec.describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state do ) gitlab_sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) visit admin_user_path(user) @@ -55,8 +56,8 @@ RSpec.describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state do visit profile_active_sessions_path expect(page).to( - have_selector('ul.list-group li.list-group-item', { text: 'Signed in on', - count: 2 })) + have_selector('ul.list-group li.list-group-item', text: 'Signed in on', + count: 2)) expect(page).to have_content( '127.0.0.1 ' \ diff --git a/spec/features/projects/blobs/balsamiq_spec.rb b/spec/features/projects/blobs/balsamiq_spec.rb new file mode 100644 index 00000000000..bce60856544 --- /dev/null +++ b/spec/features/projects/blobs/balsamiq_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Balsamiq file blob', :js do + let(:project) { create(:project, :public, :repository) } + + before do + visit project_blob_path(project, 'add-balsamiq-file/files/images/balsamiq.bmpr') + + wait_for_requests + end + + it 'displays Balsamiq file content' do + expect(page).to have_content("Mobile examples") + end +end diff --git a/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb b/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb index 6b9fd41059d..484f740faee 100644 --- a/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb +++ b/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb @@ -9,12 +9,9 @@ RSpec.describe 'User creates new blob', :js do let(:project) { create(:project, :empty_repo) } shared_examples 'creating a file' do - before do - sign_in(user) + it 'allows the user to add a new file in Web IDE' do visit project_path(project) - end - it 'allows the user to add a new file in Web IDE' do click_link 'New file' wait_for_requests @@ -31,6 +28,7 @@ RSpec.describe 'User creates new blob', :js do describe 'as a maintainer' do before do project.add_maintainer(user) + sign_in(user) end it_behaves_like 'creating a file' @@ -39,6 +37,11 @@ RSpec.describe 'User creates new blob', :js do describe 'as an admin' do let(:user) { create(:user, :admin) } + before do + sign_in(user) + gitlab_enable_admin_mode_sign_in(user) + end + it_behaves_like 'creating a file' end diff --git a/spec/features/projects/blobs/user_follows_pipeline_suggest_nudge_spec.rb b/spec/features/projects/blobs/user_follows_pipeline_suggest_nudge_spec.rb index 3069405ba63..1c79b2ddc38 100644 --- a/spec/features/projects/blobs/user_follows_pipeline_suggest_nudge_spec.rb +++ b/spec/features/projects/blobs/user_follows_pipeline_suggest_nudge_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' RSpec.describe 'User follows pipeline suggest nudge spec when feature is enabled', :js do include CookieHelper - let(:user) { create(:user, :admin) } let(:project) { create(:project, :empty_repo) } + let(:user) { project.owner } describe 'viewing the new blob page' do before do diff --git a/spec/features/projects/clusters/gcp_spec.rb b/spec/features/projects/clusters/gcp_spec.rb index a0519d88532..d34dde6a8f2 100644 --- a/spec/features/projects/clusters/gcp_spec.rb +++ b/spec/features/projects/clusters/gcp_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Gcp Cluster', :js, :do_not_mock_admin_mode do +RSpec.describe 'Gcp Cluster', :js do include GoogleApi::CloudPlatformHelpers let(:project) { create(:project) } diff --git a/spec/features/projects/diffs/diff_show_spec.rb b/spec/features/projects/diffs/diff_show_spec.rb index 19f111a727b..747277e2562 100644 --- a/spec/features/projects/diffs/diff_show_spec.rb +++ b/spec/features/projects/diffs/diff_show_spec.rb @@ -155,10 +155,6 @@ RSpec.describe 'Diff file viewer', :js do context 'binary file that appears to be text in the first 1024 bytes' do before do - # The file we're visiting is smaller than 10 KB and we want it collapsed - # so we need to disable the size increase feature. - stub_feature_flags(gitlab_git_diff_size_limit_increase: false) - visit_commit('7b1cf4336b528e0f3d1d140ee50cafdbc703597c') end diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index 8c032660726..a265e0c28fc 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -12,8 +12,16 @@ RSpec.describe 'Environments page', :js do sign_in(user) end + def actions_button_selector + '[data-testid="environment-actions-button"]' + end + + def action_link_selector + '[data-testid="manual-action-link"]' + end + def stop_button_selector - %q{button[title="Stop environment"]} + 'button[title="Stop environment"]' end describe 'page tabs' do @@ -187,18 +195,17 @@ RSpec.describe 'Environments page', :js do end it 'shows a play button' do - find('.js-environment-actions-dropdown').click - + find(actions_button_selector).click expect(page).to have_content(action.name) end it 'allows to play a manual action', :js do expect(action).to be_manual - find('.js-environment-actions-dropdown').click + find(actions_button_selector).click expect(page).to have_content(action.name) - expect { find('.js-manual-action-link').click } + expect { find(action_link_selector).click } .not_to change { Ci::Pipeline.count } end @@ -301,11 +308,11 @@ RSpec.describe 'Environments page', :js do end it 'has a dropdown for actionable jobs' do - expect(page).to have_selector('.dropdown-new.btn.btn-default [data-testid="play-icon"]') + expect(page).to have_selector("#{actions_button_selector} [data-testid=\"play-icon\"]") end it "has link to the delayed job's action" do - find('.js-environment-actions-dropdown').click + find(actions_button_selector).click expect(page).to have_button('delayed job') expect(page).to have_content(/\d{2}:\d{2}:\d{2}/) @@ -320,7 +327,7 @@ RSpec.describe 'Environments page', :js do end it "shows 00:00:00 as the remaining time" do - find('.js-environment-actions-dropdown').click + find(actions_button_selector).click expect(page).to have_content("00:00:00") end @@ -328,8 +335,8 @@ RSpec.describe 'Environments page', :js do context 'when user played a delayed job immediately' do before do - find('.js-environment-actions-dropdown').click - page.accept_confirm { click_button('delayed job') } + find(actions_button_selector).click + accept_confirm { find(action_link_selector).click } wait_for_requests end diff --git a/spec/features/projects/features_visibility_spec.rb b/spec/features/projects/features_visibility_spec.rb index 467adb25a17..904b4bda0e0 100644 --- a/spec/features/projects/features_visibility_spec.rb +++ b/spec/features/projects/features_visibility_spec.rb @@ -150,6 +150,7 @@ RSpec.describe 'Edit Project Settings' do before do non_member.update_attribute(:admin, true) sign_in(non_member) + gitlab_enable_admin_mode_sign_in(non_member) end it 'renders 404 if feature is disabled' do diff --git a/spec/features/projects/gfm_autocomplete_load_spec.rb b/spec/features/projects/gfm_autocomplete_load_spec.rb index b02483be489..f4cd65bcba1 100644 --- a/spec/features/projects/gfm_autocomplete_load_spec.rb +++ b/spec/features/projects/gfm_autocomplete_load_spec.rb @@ -6,7 +6,7 @@ RSpec.describe 'GFM autocomplete loading', :js do let(:project) { create(:project) } before do - sign_in(create(:admin)) + sign_in(project.owner) visit project_path(project) end diff --git a/spec/features/projects/import_export/import_file_spec.rb b/spec/features/projects/import_export/import_file_spec.rb index 83ceffa621c..af228764c17 100644 --- a/spec/features/projects/import_export/import_file_spec.rb +++ b/spec/features/projects/import_export/import_file_spec.rb @@ -28,73 +28,40 @@ RSpec.describe 'Import/Export - project import integration test', :js do let(:project_name) { 'Test Project Name' + randomHex } let(:project_path) { 'test-project-name' + randomHex } - context 'prefilled the path' do - it 'user imports an exported project successfully', :sidekiq_might_not_need_inline do - visit new_project_path + it 'user imports an exported project successfully', :sidekiq_might_not_need_inline do + visit new_project_path + click_import_project_tab + click_link 'GitLab export' - fill_in :project_name, with: project_name, visible: true - click_import_project_tab - click_link 'GitLab export' + fill_in :name, with: 'Test Project Name', visible: true + fill_in :path, with: 'test-project-path', visible: true + attach_file('file', file) - expect(page).to have_content('Import an exported GitLab project') - expect(URI.parse(current_url).query).to eq("namespace_id=#{namespace.id}&name=#{ERB::Util.url_encode(project_name)}&path=#{project_path}") + expect { click_on 'Import project' }.to change { Project.count }.by(1) - attach_file('file', file) - click_on 'Import project' - - expect(Project.count).to eq(1) - - project = Project.last - expect(project).not_to be_nil - expect(project.description).to eq("Foo Bar") - expect(project.issues).not_to be_empty - expect(project.merge_requests).not_to be_empty - expect(wiki_exists?(project)).to be true - expect(project.import_state.status).to eq('finished') - end + project = Project.last + expect(project).not_to be_nil + expect(page).to have_content("Project 'test-project-path' is being imported") end - context 'path is not prefilled' do - it 'user imports an exported project successfully', :sidekiq_might_not_need_inline do - visit new_project_path - click_import_project_tab - click_link 'GitLab export' + it 'invalid project' do + project = create(:project, namespace: user.namespace) - fill_in :name, with: 'Test Project Name', visible: true - fill_in :path, with: 'test-project-path', visible: true - attach_file('file', file) + visit new_project_path - expect { click_on 'Import project' }.to change { Project.count }.by(1) + click_import_project_tab + click_link 'GitLab export' + fill_in :name, with: project.name, visible: true + attach_file('file', file) + click_on 'Import project' - project = Project.last - expect(project).not_to be_nil - expect(page).to have_content("Project 'test-project-path' is being imported") + page.within('.flash-container') do + expect(page).to have_content('Project could not be imported') end end end - it 'invalid project' do - project = create(:project, namespace: user.namespace) - - visit new_project_path - - fill_in :project_name, with: project.name, visible: true - click_import_project_tab - click_link 'GitLab export' - attach_file('file', file) - click_on 'Import project' - - page.within('.flash-container') do - expect(page).to have_content('Project could not be imported') - end - end - - def wiki_exists?(project) - wiki = ProjectWiki.new(project) - wiki.repository.exists? && !wiki.repository.empty? - end - def click_import_project_tab - find('#import-project-tab').click + find('[data-qa-selector="import_project_link"]').click end end diff --git a/spec/features/projects/new_project_spec.rb b/spec/features/projects/new_project_spec.rb index 6a2ec9aa4a8..796fd76cfdf 100644 --- a/spec/features/projects/new_project_spec.rb +++ b/spec/features/projects/new_project_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'New project' do +RSpec.describe 'New project', :js do include Select2Helper context 'as a user' do @@ -18,6 +18,7 @@ RSpec.describe 'New project' do ) visit new_project_path + find('[data-qa-selector="blank_project_link"]').click expect(page).to have_content 'Other visibility settings have been disabled by the administrator.' end @@ -28,6 +29,7 @@ RSpec.describe 'New project' do ) visit new_project_path + find('[data-qa-selector="blank_project_link"]').click expect(page).to have_content 'Visibility settings have been disabled by the administrator.' end @@ -42,12 +44,14 @@ RSpec.describe 'New project' do it 'shows "New project" page', :js do visit new_project_path + find('[data-qa-selector="blank_project_link"]').click expect(page).to have_content('Project name') expect(page).to have_content('Project URL') expect(page).to have_content('Project slug') - find('#import-project-tab').click + click_link('New project') + find('[data-qa-selector="import_project_link"]').click expect(page).to have_link('GitHub') expect(page).to have_link('Bitbucket') @@ -61,7 +65,7 @@ RSpec.describe 'New project' do before do visit new_project_path - find('#import-project-tab').click + find('[data-qa-selector="import_project_link"]').click end it { expect(page).to have_link('Manifest file') } @@ -73,6 +77,7 @@ RSpec.describe 'New project' do stub_application_setting(default_project_visibility: level) visit new_project_path + find('[data-qa-selector="blank_project_link"]').click page.within('#blank-project-pane') do expect(find_field("project_visibility_level_#{level}")).to be_checked end @@ -80,6 +85,7 @@ RSpec.describe 'New project' do it "saves visibility level #{level} on validation error" do visit new_project_path + find('[data-qa-selector="blank_project_link"]').click choose(s_(key)) click_button('Create project') @@ -97,6 +103,7 @@ RSpec.describe 'New project' do it 'has private selected' do group = create(:group, visibility_level: Gitlab::VisibilityLevel::PRIVATE) visit new_project_path(namespace_id: group.id) + find('[data-qa-selector="blank_project_link"]').click page.within('#blank-project-pane') do expect(find_field("project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).to be_checked @@ -112,6 +119,7 @@ RSpec.describe 'New project' do it 'has private selected' do group = create(:group, visibility_level: Gitlab::VisibilityLevel::PUBLIC) visit new_project_path(namespace_id: group.id, project: { visibility_level: Gitlab::VisibilityLevel::PRIVATE }) + find('[data-qa-selector="blank_project_link"]').click page.within('#blank-project-pane') do expect(find_field("project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).to be_checked @@ -123,6 +131,7 @@ RSpec.describe 'New project' do context 'Readme selector' do it 'shows the initialize with Readme checkbox on "Blank project" tab' do visit new_project_path + find('[data-qa-selector="blank_project_link"]').click expect(page).to have_css('input#project_initialize_with_readme') expect(page).to have_content('Initialize repository with a README') @@ -130,7 +139,7 @@ RSpec.describe 'New project' do it 'does not show the initialize with Readme checkbox on "Create from template" tab' do visit new_project_path - find('#create-from-template-pane').click + find('[data-qa-selector="create_from_template_link"]').click first('.choose-template').click page.within '.project-fields-form' do @@ -141,7 +150,7 @@ RSpec.describe 'New project' do it 'does not show the initialize with Readme checkbox on "Import project" tab' do visit new_project_path - find('#import-project-tab').click + find('[data-qa-selector="import_project_link"]').click first('.js-import-git-toggle-button').click page.within '.toggle-import-form' do @@ -155,13 +164,12 @@ RSpec.describe 'New project' do context 'with user namespace' do before do visit new_project_path + find('[data-qa-selector="blank_project_link"]').click end it 'selects the user namespace' do page.within('#blank-project-pane') do - namespace = find('#project_namespace_id') - - expect(namespace.text).to eq user.username + expect(page).to have_select('project[namespace_id]', visible: false, selected: user.username) end end end @@ -172,13 +180,12 @@ RSpec.describe 'New project' do before do group.add_owner(user) visit new_project_path(namespace_id: group.id) + find('[data-qa-selector="blank_project_link"]').click end it 'selects the group namespace' do page.within('#blank-project-pane') do - namespace = find('#project_namespace_id option[selected]') - - expect(namespace.text).to eq group.name + expect(page).to have_select('project[namespace_id]', visible: false, selected: group.name) end end end @@ -190,13 +197,12 @@ RSpec.describe 'New project' do before do group.add_maintainer(user) visit new_project_path(namespace_id: subgroup.id) + find('[data-qa-selector="blank_project_link"]').click end it 'selects the group namespace' do page.within('#blank-project-pane') do - namespace = find('#project_namespace_id option[selected]') - - expect(namespace.text).to eq subgroup.full_path + expect(page).to have_select('project[namespace_id]', visible: false, selected: subgroup.full_path) end end end @@ -211,6 +217,7 @@ RSpec.describe 'New project' do internal_group.add_owner(user) private_group.add_owner(user) visit new_project_path(namespace_id: public_group.id) + find('[data-qa-selector="blank_project_link"]').click end it 'enables the correct visibility options' do @@ -240,7 +247,7 @@ RSpec.describe 'New project' do context 'Import project options', :js do before do visit new_project_path - find('#import-project-tab').click + find('[data-qa-selector="import_project_link"]').click end context 'from git repository url, "Repo by URL"' do @@ -315,13 +322,12 @@ RSpec.describe 'New project' do before do group.add_developer(user) visit new_project_path(namespace_id: group.id) + find('[data-qa-selector="blank_project_link"]').click end it 'selects the group namespace' do page.within('#blank-project-pane') do - namespace = find('#project_namespace_id option[selected]') - - expect(namespace.text).to eq group.full_path + expect(page).to have_select('project[namespace_id]', visible: false, selected: group.full_path) end end end diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb index 8c7b7bc70a2..3e520142117 100644 --- a/spec/features/projects/settings/repository_settings_spec.rb +++ b/spec/features/projects/settings/repository_settings_spec.rb @@ -289,13 +289,13 @@ RSpec.describe 'Projects > Settings > Repository settings' do visit project_settings_repository_path(project) end - context 'when project mirroring is enabled' do + context 'when project mirroring is enabled', :enable_admin_mode do let(:mirror_available) { true } include_examples 'shows mirror settings' end - context 'when project mirroring is disabled' do + context 'when project mirroring is disabled', :enable_admin_mode do let(:mirror_available) { false } include_examples 'shows mirror settings' diff --git a/spec/features/projects/show/no_password_spec.rb b/spec/features/projects/show/no_password_spec.rb index 79cd65e5406..d18ff75b324 100644 --- a/spec/features/projects/show/no_password_spec.rb +++ b/spec/features/projects/show/no_password_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'No Password Alert' do let(:user) { create(:user) } it 'shows no alert' do - expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you set a password on your account" + expect(page).not_to have_content "You won't be able to pull or push repositories via HTTP until you set a password on your account" end end @@ -23,7 +23,7 @@ RSpec.describe 'No Password Alert' do let(:user) { create(:user, password_automatically_set: true) } it 'shows a password alert' do - expect(page).to have_content "You won't be able to pull or push project code via HTTP until you set a password on your account" + expect(page).to have_content "You won't be able to pull or push repositories via HTTP until you set a password on your account" end end end @@ -41,7 +41,7 @@ RSpec.describe 'No Password Alert' do gitlab_sign_in_via('saml', user, 'my-uid') visit project_path(project) - expect(page).to have_content "You won't be able to pull or push project code via HTTP until you create a personal access token on your account" + expect(page).to have_content "You won't be able to pull or push repositories via HTTP until you create a personal access token on your account" end end @@ -51,7 +51,7 @@ RSpec.describe 'No Password Alert' do gitlab_sign_in_via('saml', user, 'my-uid') visit project_path(project) - expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you create a personal access token on your account" + expect(page).not_to have_content "You won't be able to pull or push repositories via HTTP until you create a personal access token on your account" end end end @@ -65,7 +65,7 @@ RSpec.describe 'No Password Alert' do end it 'shows no alert' do - expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you" + expect(page).not_to have_content "You won't be able to pull or push repositories via HTTP until you" end end end diff --git a/spec/features/projects/show/schema_markup_spec.rb b/spec/features/projects/show/schema_markup_spec.rb index e651798af23..1777b72cbf5 100644 --- a/spec/features/projects/show/schema_markup_spec.rb +++ b/spec/features/projects/show/schema_markup_spec.rb @@ -14,7 +14,7 @@ RSpec.describe 'Projects > Show > Schema Markup' do expect(page).to have_selector('img[itemprop="image"]') expect(page).to have_selector('[itemprop="name"]', text: project.name) expect(page).to have_selector('[itemprop="identifier"]', text: "Project ID: #{project.id}") - expect(page).to have_selector('[itemprop="abstract"]', text: project.description) + expect(page).to have_selector('[itemprop="description"]', text: project.description) expect(page).to have_selector('[itemprop="license"]', text: project.repository.license.name) expect(find_all('[itemprop="keywords"]').map(&:text)).to match_array(project.tag_list.map(&:capitalize)) expect(page).to have_selector('[itemprop="about"]') diff --git a/spec/features/projects/user_creates_project_spec.rb b/spec/features/projects/user_creates_project_spec.rb index b204ae76e07..feb5f348256 100644 --- a/spec/features/projects/user_creates_project_spec.rb +++ b/spec/features/projects/user_creates_project_spec.rb @@ -13,6 +13,7 @@ RSpec.describe 'User creates a project', :js do it 'creates a new project' do visit(new_project_path) + find('[data-qa-selector="blank_project_link"]').click fill_in(:project_name, with: 'Empty') page.within('#content-body') do @@ -39,6 +40,7 @@ RSpec.describe 'User creates a project', :js do it 'creates a new project' do visit(new_project_path) + find('[data-qa-selector="blank_project_link"]').click fill_in :project_name, with: 'A Subgroup Project' fill_in :project_path, with: 'a-subgroup-project' @@ -67,6 +69,7 @@ RSpec.describe 'User creates a project', :js do it 'creates a new project' do visit(new_project_path) + find('[data-qa-selector="blank_project_link"]').click fill_in :project_name, with: 'a-new-project' fill_in :project_path, with: 'a-new-project' diff --git a/spec/features/projects/user_sorts_projects_spec.rb b/spec/features/projects/user_sorts_projects_spec.rb new file mode 100644 index 00000000000..6a5ed49f1a6 --- /dev/null +++ b/spec/features/projects/user_sorts_projects_spec.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'User sorts projects and order persists' do + include CookieHelper + + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group) } + let_it_be(:group_member) { create(:group_member, :maintainer, user: user, group: group) } + let_it_be(:project) { create(:project, :public, group: group) } + + shared_examples_for "sort order persists across all views" do |project_paths_label, group_paths_label| + it "is set on the dashboard_projects_path" do + visit(dashboard_projects_path) + + expect(find('.dropdown-menu a.is-active', text: project_paths_label)).to have_content(project_paths_label) + end + + it "is set on the explore_projects_path" do + visit(explore_projects_path) + + expect(find('.dropdown-menu a.is-active', text: project_paths_label)).to have_content(project_paths_label) + end + + it "is set on the group_canonical_path" do + visit(group_canonical_path(group)) + + expect(find('.dropdown-menu a.is-active', text: group_paths_label)).to have_content(group_paths_label) + end + + it "is set on the details_group_path" do + visit(details_group_path(group)) + + expect(find('.dropdown-menu a.is-active', text: group_paths_label)).to have_content(group_paths_label) + end + end + + context "from explore projects" do + before do + sign_in(user) + visit(explore_projects_path) + find('#sort-projects-dropdown').click + first(:link, 'Last updated').click + end + + it_behaves_like "sort order persists across all views", "Last updated", "Last updated" + end + + context 'from dashboard projects' do + before do + sign_in(user) + visit(dashboard_projects_path) + find('#sort-projects-dropdown').click + first(:link, 'Name').click + end + + it_behaves_like "sort order persists across all views", "Name", "Name" + end + + context 'from group homepage' do + before do + sign_in(user) + visit(group_canonical_path(group)) + find('button.dropdown-menu-toggle').click + first(:link, 'Last created').click + end + + it_behaves_like "sort order persists across all views", "Created date", "Last created" + end + + context 'from group details' do + before do + sign_in(user) + visit(details_group_path(group)) + find('button.dropdown-menu-toggle').click + first(:link, 'Most stars').click + end + + it_behaves_like "sort order persists across all views", "Stars", "Most stars" + end +end diff --git a/spec/features/projects/user_views_empty_project_spec.rb b/spec/features/projects/user_views_empty_project_spec.rb index 9202d18b86f..3d4d9a7ea96 100644 --- a/spec/features/projects/user_views_empty_project_spec.rb +++ b/spec/features/projects/user_views_empty_project_spec.rb @@ -7,12 +7,9 @@ RSpec.describe 'User views an empty project' do let(:user) { create(:user) } shared_examples 'allowing push to default branch' do - before do - sign_in(user) + it 'shows push-to-master instructions' do visit project_path(project) - end - it 'shows push-to-master instructions' do expect(page).to have_content('git push -u origin master') end end @@ -20,6 +17,7 @@ RSpec.describe 'User views an empty project' do describe 'as a maintainer' do before do project.add_maintainer(user) + sign_in(user) end it_behaves_like 'allowing push to default branch' @@ -28,17 +26,33 @@ RSpec.describe 'User views an empty project' do describe 'as an admin' do let(:user) { create(:user, :admin) } - it_behaves_like 'allowing push to default branch' + 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' + 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 before do project.add_developer(user) sign_in(user) - visit project_path(project) end 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 diff --git a/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb b/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb deleted file mode 100644 index 83679c6bd1d..00000000000 --- a/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Projects > Wiki > User views Git access wiki page' do - let(:user) { create(:user) } - let(:project) { create(:project, :wiki_repo, :public) } - let(:wiki_page) { create(:wiki_page, wiki: project.wiki, title: 'home', content: '[some link](other-page)') } - - before do - sign_in(user) - end - - it 'Visit Wiki Page Current Commit' do - visit project_wiki_path(project, wiki_page) - - click_link 'Clone repository' - expect(page).to have_text("Clone repository #{project.wiki.full_path}") - expect(page).to have_text(project.wiki.http_url_to_repo) - end -end diff --git a/spec/features/projects/wikis_spec.rb b/spec/features/projects/wikis_spec.rb index 1c66ad81145..621f8c71b20 100644 --- a/spec/features/projects/wikis_spec.rb +++ b/spec/features/projects/wikis_spec.rb @@ -17,4 +17,5 @@ RSpec.describe 'Project wikis' do it_behaves_like 'User views a wiki page' it_behaves_like 'User views wiki pages' it_behaves_like 'User views wiki sidebar' + it_behaves_like 'User views Git access wiki page' end diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index 9b5f4ca6d48..e67fb9c2bd6 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -16,7 +16,7 @@ RSpec.describe 'Project' do shared_examples 'creates from template' do |template, sub_template_tab = nil| it "is created from template", :js do - find('#create-from-template-tab').click + find('[data-qa-selector="create_from_template_link"]').click find(".project-template #{sub_template_tab}").click if sub_template_tab find("label[for=#{template.name}]").click fill_in("project_name", with: template.name) @@ -47,9 +47,7 @@ RSpec.describe 'Project' do end it 'shows the command in a popover', :js do - page.within '.profile-settings-sidebar' do - click_link 'Show command' - end + click_link 'Show command' expect(page).to have_css('.popover .push-to-create-popover #push_to_create_tip') expect(page).to have_content 'Private projects can be created in your personal namespace with:' @@ -61,7 +59,7 @@ RSpec.describe 'Project' do let(:path) { project_path(project) } before do - sign_in(create(:admin)) + sign_in(project.owner) end it 'parses Markdown' do @@ -125,7 +123,7 @@ RSpec.describe 'Project' do let(:path) { project_path(project) } before do - sign_in(create(:admin)) + sign_in(project.owner) visit path end @@ -156,7 +154,7 @@ RSpec.describe 'Project' do let(:path) { project_path(project) } before do - sign_in(create(:admin)) + sign_in(project.owner) visit path end diff --git a/spec/features/protected_branches_spec.rb b/spec/features/protected_branches_spec.rb index 3be01595502..95d268ab1be 100644 --- a/spec/features/protected_branches_spec.rb +++ b/spec/features/protected_branches_spec.rb @@ -73,6 +73,7 @@ RSpec.describe 'Protected Branches', :js do context 'logged in as admin' do before do sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) end describe "explicit protected branches" do diff --git a/spec/features/protected_tags_spec.rb b/spec/features/protected_tags_spec.rb index 12e4bbde293..25447db3c8d 100644 --- a/spec/features/protected_tags_spec.rb +++ b/spec/features/protected_tags_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' RSpec.describe 'Protected Tags', :js do include ProtectedTagHelpers - let(:user) { create(:user, :admin) } let(:project) { create(:project, :repository) } + let(:user) { project.owner } before do sign_in(user) diff --git a/spec/features/registrations/experience_level_spec.rb b/spec/features/registrations/experience_level_spec.rb index 06d380926cd..30f19870f69 100644 --- a/spec/features/registrations/experience_level_spec.rb +++ b/spec/features/registrations/experience_level_spec.rb @@ -23,14 +23,14 @@ RSpec.describe 'Experience level screen' do it 'shows the option for novice' do is_expected.to have_content('Novice') - is_expected.to have_content('I’m not very familiar with the basics of project management and DevOps') - is_expected.to have_content('Show me everything') + is_expected.to have_content('I’m not familiar with the basics of DevOps') + is_expected.to have_content('Show me the basics') end it 'shows the option for experienced' do is_expected.to have_content('Experienced') - is_expected.to have_content('I’m familiar with the basics of project management and DevOps') - is_expected.to have_content('Show me more advanced stuff') + is_expected.to have_content('I’m familiar with the basics of DevOps') + is_expected.to have_content('Show me advanced features') end it 'does not display any flash messages' do diff --git a/spec/features/security/admin_access_spec.rb b/spec/features/security/admin_access_spec.rb index 38f00f399f3..8070ae066e7 100644 --- a/spec/features/security/admin_access_spec.rb +++ b/spec/features/security/admin_access_spec.rb @@ -8,7 +8,14 @@ RSpec.describe "Admin::Projects" do describe "GET /admin/projects" do subject { admin_projects_path } - it { is_expected.to be_allowed_for :admin } + context 'when admin mode is enabled', :enable_admin_mode do + 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 :visitor } end @@ -16,7 +23,14 @@ RSpec.describe "Admin::Projects" do describe "GET /admin/users" do subject { admin_users_path } - it { is_expected.to be_allowed_for :admin } + context 'when admin mode is enabled', :enable_admin_mode do + 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 :visitor } end @@ -24,7 +38,14 @@ RSpec.describe "Admin::Projects" do describe "GET /admin/hooks" do subject { admin_hooks_path } - it { is_expected.to be_allowed_for :admin } + context 'when admin mode is enabled', :enable_admin_mode do + 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 :visitor } end diff --git a/spec/features/security/project/internal_access_spec.rb b/spec/features/security/project/internal_access_spec.rb index 051bd601c1d..cb9f9a6e680 100644 --- a/spec/features/security/project/internal_access_spec.rb +++ b/spec/features/security/project/internal_access_spec.rb @@ -102,7 +102,8 @@ RSpec.describe "Internal Project Access" do describe "GET /:project_path/-/settings/ci_cd" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -116,7 +117,8 @@ RSpec.describe "Internal Project Access" do describe "GET /:project_path/-/settings/repository" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -146,7 +148,8 @@ RSpec.describe "Internal Project Access" do describe "GET /:project_path/edit" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -160,7 +163,8 @@ RSpec.describe "Internal Project Access" do describe "GET /:project_path/deploy_keys" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -190,7 +194,8 @@ RSpec.describe "Internal Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -218,7 +223,8 @@ RSpec.describe "Internal Project Access" do describe "GET /:project_path/snippets/new" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -246,7 +252,8 @@ RSpec.describe "Internal Project Access" do describe "GET /:project_path/-/merge_requests/new" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -302,7 +309,8 @@ RSpec.describe "Internal Project Access" do describe "GET /:project_path/-/settings/integrations" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -367,7 +375,8 @@ RSpec.describe "Internal Project Access" do project.update(public_builds: false) 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -406,7 +415,8 @@ RSpec.describe "Internal Project Access" do project.update(public_builds: false) 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -445,7 +455,8 @@ RSpec.describe "Internal Project Access" do project.update(public_builds: false) 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -460,7 +471,8 @@ RSpec.describe "Internal Project Access" do describe "GET /:project_path/pipeline_schedules" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -474,7 +486,8 @@ RSpec.describe "Internal Project Access" do describe "GET /:project_path/-/environments" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -490,7 +503,8 @@ RSpec.describe "Internal Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -506,7 +520,8 @@ RSpec.describe "Internal Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -520,7 +535,8 @@ RSpec.describe "Internal Project Access" do describe "GET /:project_path/-/environments/new" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } diff --git a/spec/features/security/project/private_access_spec.rb b/spec/features/security/project/private_access_spec.rb index e891e79db70..dda218c5de5 100644 --- a/spec/features/security/project/private_access_spec.rb +++ b/spec/features/security/project/private_access_spec.rb @@ -18,7 +18,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -32,7 +33,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/-/tree/master" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -46,7 +48,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/-/commits/master" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -60,7 +63,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/-/commit/:sha" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -74,7 +78,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/-/compare" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -88,7 +93,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/-/project_members" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -102,7 +108,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/-/settings/ci_cd" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -116,7 +123,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/-/settings/repository" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -132,7 +140,8 @@ RSpec.describe "Private Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -146,7 +155,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/edit" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -160,7 +170,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/deploy_keys" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -174,7 +185,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/issues" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -190,7 +202,8 @@ RSpec.describe "Private Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -204,7 +217,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/snippets" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -218,7 +232,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/-/merge_requests" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -239,7 +254,8 @@ RSpec.describe "Private Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -260,7 +276,8 @@ RSpec.describe "Private Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -274,7 +291,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/-/settings/integrations" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -288,7 +306,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/pipelines" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -316,7 +335,8 @@ RSpec.describe "Private Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -342,7 +362,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/builds" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -371,7 +392,8 @@ RSpec.describe "Private Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -405,7 +427,8 @@ RSpec.describe "Private Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -435,7 +458,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/-/environments" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -451,7 +475,8 @@ RSpec.describe "Private Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -467,7 +492,8 @@ RSpec.describe "Private Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -481,7 +507,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/-/environments/new" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -495,7 +522,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/pipeline_schedules" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -509,7 +537,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/pipeline_schedules/new" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -523,7 +552,8 @@ RSpec.describe "Private Project Access" do describe "GET /:project_path/-/environments/new" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -545,7 +575,8 @@ RSpec.describe "Private Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb index 75993959f6e..f2dbab72a48 100644 --- a/spec/features/security/project/public_access_spec.rb +++ b/spec/features/security/project/public_access_spec.rb @@ -102,7 +102,8 @@ RSpec.describe "Public Project Access" do describe "GET /:project_path/-/settings/ci_cd" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -116,7 +117,8 @@ RSpec.describe "Public Project Access" do describe "GET /:project_path/-/settings/repository" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -181,7 +183,8 @@ RSpec.describe "Public Project Access" do project.update(public_builds: false) 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -220,7 +223,8 @@ RSpec.describe "Public Project Access" do project.update(public_builds: false) 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -259,7 +263,8 @@ RSpec.describe "Public Project Access" do project.update(public_builds: false) 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -274,7 +279,8 @@ RSpec.describe "Public Project Access" do describe "GET /:project_path/pipeline_schedules" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -288,7 +294,8 @@ RSpec.describe "Public Project Access" do describe "GET /:project_path/-/environments" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -304,7 +311,8 @@ RSpec.describe "Public Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -320,7 +328,8 @@ RSpec.describe "Public Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -334,7 +343,8 @@ RSpec.describe "Public Project Access" do describe "GET /:project_path/-/environments/new" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -363,7 +373,8 @@ RSpec.describe "Public Project Access" do describe "GET /:project_path/edit" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -377,7 +388,8 @@ RSpec.describe "Public Project Access" do describe "GET /:project_path/deploy_keys" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } @@ -407,7 +419,8 @@ RSpec.describe "Public Project Access" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -435,7 +448,8 @@ RSpec.describe "Public Project Access" do describe "GET /:project_path/snippets/new" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -463,7 +477,8 @@ RSpec.describe "Public Project Access" do describe "GET /:project_path/-/merge_requests/new" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -519,7 +534,8 @@ RSpec.describe "Public Project Access" do describe "GET /:project_path/-/settings/integrations" do 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(:maintainer).of(project) } it { is_expected.to be_denied_for(:developer).of(project) } diff --git a/spec/features/security/project/snippet/internal_access_spec.rb b/spec/features/security/project/snippet/internal_access_spec.rb index 0667a2fd48a..12237863188 100644 --- a/spec/features/security/project/snippet/internal_access_spec.rb +++ b/spec/features/security/project/snippet/internal_access_spec.rb @@ -26,7 +26,8 @@ RSpec.describe "Internal Project Snippets Access" do describe "GET /:project_path/snippets/new" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -55,7 +56,8 @@ RSpec.describe "Internal Project Snippets Access" do context "for a private snippet" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -85,7 +87,8 @@ RSpec.describe "Internal Project Snippets Access" do context "for a private snippet" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } diff --git a/spec/features/security/project/snippet/private_access_spec.rb b/spec/features/security/project/snippet/private_access_spec.rb index 0c97b012ad1..0f7ae06a6c5 100644 --- a/spec/features/security/project/snippet/private_access_spec.rb +++ b/spec/features/security/project/snippet/private_access_spec.rb @@ -12,7 +12,8 @@ RSpec.describe "Private Project Snippets Access" do describe "GET /:project_path/snippets" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -26,7 +27,8 @@ RSpec.describe "Private Project Snippets Access" do describe "GET /:project_path/snippets/new" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -40,7 +42,8 @@ RSpec.describe "Private Project Snippets Access" do describe "GET /:project_path/snippets/:id for a private snippet" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -54,7 +57,8 @@ RSpec.describe "Private Project Snippets Access" do describe "GET /:project_path/snippets/:id/raw for a private snippet" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } diff --git a/spec/features/security/project/snippet/public_access_spec.rb b/spec/features/security/project/snippet/public_access_spec.rb index 20a271f9c0e..2ae08205602 100644 --- a/spec/features/security/project/snippet/public_access_spec.rb +++ b/spec/features/security/project/snippet/public_access_spec.rb @@ -27,7 +27,8 @@ RSpec.describe "Public Project Snippets Access" do describe "GET /:project_path/snippets/new" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -70,7 +71,8 @@ RSpec.describe "Public Project Snippets Access" do context "for a private snippet" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } @@ -114,7 +116,8 @@ RSpec.describe "Public Project Snippets Access" do context "for a private snippet" do 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(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } diff --git a/spec/features/usage_stats_consent_spec.rb b/spec/features/usage_stats_consent_spec.rb index 04bdf25acc0..6fa1d7d76b5 100644 --- a/spec/features/usage_stats_consent_spec.rb +++ b/spec/features/usage_stats_consent_spec.rb @@ -19,6 +19,7 @@ RSpec.describe 'Usage stats consent' do end gitlab_sign_in(user) + gitlab_enable_admin_mode_sign_in(user) end it 'hides the banner permanently when sets usage stats' do |