diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-18 18:15:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-18 18:15:16 +0300 |
commit | 9ee9d3012b3747270beb6dec6200d632d8afd0e3 (patch) | |
tree | 13dd297abb01c7b45261289c1f97a63dcd0a9fc3 /spec | |
parent | 00cfeb7c25bdbd460efb83ad846cb924e73ee150 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
23 files changed, 170 insertions, 86 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 047dd12912b..f4384dbaa69 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -19,7 +19,7 @@ RSpec.describe ApplicationController, feature_category: :shared do expect(user.ldap_user?).to be_falsey allow(controller).to receive(:current_user).and_return(user) expect(controller).to receive(:redirect_to) - expect(controller).to receive(:new_profile_password_path) + expect(controller).to receive(:new_user_settings_password_path) controller.send(:check_password_expiration) end diff --git a/spec/controllers/ldap/omniauth_callbacks_controller_spec.rb b/spec/controllers/ldap/omniauth_callbacks_controller_spec.rb index 29678706bba..b16f8ad1a58 100644 --- a/spec/controllers/ldap/omniauth_callbacks_controller_spec.rb +++ b/spec/controllers/ldap/omniauth_callbacks_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Ldap::OmniauthCallbacksController do +RSpec.describe Ldap::OmniauthCallbacksController, type: :controller, feature_category: :system_access do include_context 'Ldap::OmniauthCallbacksController' it 'allows sign in' do diff --git a/spec/factories/namespace_package_settings.rb b/spec/factories/namespace_package_settings.rb index 9d794e794a4..33f290d0a2d 100644 --- a/spec/factories/namespace_package_settings.rb +++ b/spec/factories/namespace_package_settings.rb @@ -13,6 +13,8 @@ FactoryBot.define do nuget_duplicates_allowed { true } nuget_duplicate_exception_regex { 'foo' } + nuget_symbol_server_enabled { false } + trait :group do namespace { association(:group) } end diff --git a/spec/features/profiles/password_spec.rb b/spec/features/user_settings/password_spec.rb index 05e492e7021..76e3f85e021 100644 --- a/spec/features/profiles/password_spec.rb +++ b/spec/features/user_settings/password_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Profile > Password', feature_category: :user_profile do +RSpec.describe 'User Settings > Password', feature_category: :user_profile do let(:user) { create(:user) } def fill_passwords(password, confirmation) @@ -12,16 +12,16 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do click_button 'Save password' end - context 'Password authentication enabled' do + context 'when password authentication enabled' do let(:new_password) { User.random_password } let(:user) { create(:user, password_automatically_set: true) } before do sign_in(user) - visit edit_profile_password_path + visit edit_user_settings_password_path end - context 'User with password automatically set' do + context 'when User with password automatically set' do describe 'User puts different passwords in the field and in the confirmation' do it 'shows an error message' do fill_passwords(new_password, "#{new_password}2") @@ -42,7 +42,7 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do it 'shows a success message' do fill_passwords(new_password, new_password) - page.within('[data-testid="alert-info"]') do + within_testid('alert-info') do expect(page).to have_content('Password was successfully updated. Please sign in again.') end end @@ -50,8 +50,8 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do end end - context 'Password authentication unavailable' do - context 'Regular user' do + context 'when password authentication unavailable' do + context 'with Regular user' do before do gitlab_sign_in(user) end @@ -62,13 +62,13 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do stub_application_setting(password_authentication_enabled_for_web: false) stub_application_setting(password_authentication_enabled_for_git: false) - visit edit_profile_password_path + visit edit_user_settings_password_path expect(page).to have_gitlab_http_status(:not_found) end end - context 'LDAP user' do + context 'with LDAP user' do include LdapHelpers let(:ldap_settings) { { enabled: true } } @@ -87,7 +87,7 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do end it 'renders 404', :js do - visit edit_profile_password_path + visit edit_user_settings_password_path expect(page).to have_title('Not Found') expect(page).to have_content('Page Not Found') @@ -95,12 +95,12 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do end end - context 'Change password' do + context 'when changing password' do let(:new_password) { User.random_password } before do sign_in(user) - visit(edit_profile_password_path) + visit(edit_user_settings_password_path) end shared_examples 'user enters an incorrect current password' do @@ -113,7 +113,8 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do it 'handles the invalid password attempt, and prompts the user to try again', :aggregate_failures do expect(Gitlab::AppLogger).to receive(:info) - .with(message: 'Invalid current password when attempting to update user password', username: user.username, ip: user.current_sign_in_ip) + .with(message: 'Invalid current password when attempting to update user password', username: user.username, + ip: user.current_sign_in_ip) subject @@ -121,7 +122,7 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do expect(user.failed_attempts).to eq(1) expect(user.valid_password?(new_password)).to eq(false) - expect(page).to have_current_path(edit_profile_password_path, ignore_query: true) + expect(page).to have_current_path(edit_user_settings_password_path, ignore_query: true) page.within '.flash-container' do expect(page).to have_content('You must provide a valid current password') @@ -174,7 +175,7 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do expect_snowplow_event( category: 'Gitlab::Tracking::Helpers::WeakPasswordErrorEvent', action: 'track_weak_password_error', - controller: 'Profiles::PasswordsController', + controller: 'UserSettings::PasswordsController', method: 'update' ) end @@ -207,13 +208,12 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do user.update!(password_expires_at: 1.hour.ago) user.identities.delete - expect(user.ldap_user?).to eq false end it 'needs change user password' do - visit edit_profile_password_path + visit edit_user_settings_password_path - expect(page).to have_current_path new_profile_password_path, ignore_query: true + expect(page).to have_current_path new_user_settings_password_path, ignore_query: true fill_in :user_password, with: user.password fill_in :user_new_password, with: new_password @@ -224,9 +224,9 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do end it 'tracks weak password error' do - visit edit_profile_password_path + visit edit_user_settings_password_path - expect(page).to have_current_path new_profile_password_path, ignore_query: true + expect(page).to have_current_path new_user_settings_password_path, ignore_query: true fill_in :user_password, with: user.password fill_in :user_new_password, with: "password" @@ -235,7 +235,7 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do expect_snowplow_event( category: 'Gitlab::Tracking::Helpers::WeakPasswordErrorEvent', action: 'track_weak_password_error', - controller: 'Profiles::PasswordsController', + controller: 'UserSettings::PasswordsController', method: 'create' ) end @@ -246,7 +246,7 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do visit profile_path - expect(page).to have_current_path new_profile_password_path, ignore_query: true + expect(page).to have_current_path new_user_settings_password_path, ignore_query: true end end end diff --git a/spec/features/users/login_spec.rb b/spec/features/users/login_spec.rb index 63b4d6f7155..87ed4ced684 100644 --- a/spec/features/users/login_spec.rb +++ b/spec/features/users/login_spec.rb @@ -578,7 +578,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ fill_in 'user_password', with: user.password click_button 'Sign in' - expect(page).to have_current_path(new_profile_password_path, ignore_query: true) + expect(page).to have_current_path(new_user_settings_password_path, ignore_query: true) end end end @@ -1055,7 +1055,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ expect_to_be_on_terms_page click_button 'Accept terms' - expect(page).to have_current_path(new_profile_password_path, ignore_query: true) + expect(page).to have_current_path(new_user_settings_password_path, ignore_query: true) new_password = User.random_password diff --git a/spec/finders/milestones_finder_spec.rb b/spec/finders/milestones_finder_spec.rb index 80819a5760c..dee73625cb8 100644 --- a/spec/finders/milestones_finder_spec.rb +++ b/spec/finders/milestones_finder_spec.rb @@ -101,6 +101,13 @@ RSpec.describe MilestonesFinder do expect(result).to contain_exactly(milestone_1, milestone_2) end + it 'filters by id or title' do + params[:ids] = [milestone_2.id] + params[:title] = [milestone_1.title] + + expect(result).to contain_exactly(milestone_1, milestone_2) + end + it 'filters by active state' do params[:state] = 'active' diff --git a/spec/graphql/mutations/namespace/package_settings/update_spec.rb b/spec/graphql/mutations/namespace/package_settings/update_spec.rb index f4e79481d44..b184baaca3e 100644 --- a/spec/graphql/mutations/namespace/package_settings/update_spec.rb +++ b/spec/graphql/mutations/namespace/package_settings/update_spec.rb @@ -38,7 +38,8 @@ RSpec.describe Mutations::Namespace::PackageSettings::Update, feature_category: npm_package_requests_forwarding: nil, lock_npm_package_requests_forwarding: false, pypi_package_requests_forwarding: nil, - lock_pypi_package_requests_forwarding: false + lock_pypi_package_requests_forwarding: false, + nuget_symbol_server_enabled: false }, to: { maven_duplicates_allowed: false, maven_duplicate_exception_regex: 'RELEASE', @@ -51,7 +52,8 @@ RSpec.describe Mutations::Namespace::PackageSettings::Update, feature_category: npm_package_requests_forwarding: true, lock_npm_package_requests_forwarding: true, pypi_package_requests_forwarding: true, - lock_pypi_package_requests_forwarding: true + lock_pypi_package_requests_forwarding: true, + nuget_symbol_server_enabled: true } it_behaves_like 'returning a success' @@ -106,7 +108,8 @@ RSpec.describe Mutations::Namespace::PackageSettings::Update, feature_category: npm_package_requests_forwarding: true, lock_npm_package_requests_forwarding: true, pypi_package_requests_forwarding: true, - lock_pypi_package_requests_forwarding: true + lock_pypi_package_requests_forwarding: true, + nuget_symbol_server_enabled: true } end diff --git a/spec/graphql/types/namespace/package_settings_type_spec.rb b/spec/graphql/types/namespace/package_settings_type_spec.rb index d823f2017b6..0e731c1e2bf 100644 --- a/spec/graphql/types/namespace/package_settings_type_spec.rb +++ b/spec/graphql/types/namespace/package_settings_type_spec.rb @@ -32,6 +32,7 @@ RSpec.describe GitlabSchema.types['PackageSettings'], feature_category: :package maven_package_requests_forwarding_locked npm_package_requests_forwarding_locked pypi_package_requests_forwarding_locked + nuget_symbol_server_enabled ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index e612f48cd50..7ce1a7ef2ea 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -276,7 +276,7 @@ RSpec.describe ProjectsHelper, feature_category: :source_code_management do it 'returns message prompting user to set password or set up a PAT' do stub_application_setting(password_authentication_enabled_for_git?: true) - expect(helper.no_password_message).to eq('Your account is authenticated with SSO or SAML. To <a href="/help/topics/git/terminology#pull-and-push" target="_blank" rel="noopener noreferrer">push and pull</a> over HTTP with Git using this account, you must <a href="/-/profile/password/edit">set a password</a> or <a href="/-/user_settings/personal_access_tokens">set up a Personal Access Token</a> to use instead of a password. For more information, see <a href="/help/gitlab-basics/start-using-git#clone-with-https" target="_blank" rel="noopener noreferrer">Clone with HTTPS</a>.') + expect(helper.no_password_message).to eq('Your account is authenticated with SSO or SAML. To <a href="/help/topics/git/terminology#pull-and-push" target="_blank" rel="noopener noreferrer">push and pull</a> over HTTP with Git using this account, you must <a href="/-/user_settings/password/edit">set a password</a> or <a href="/-/user_settings/personal_access_tokens">set up a Personal Access Token</a> to use instead of a password. For more information, see <a href="/help/gitlab-basics/start-using-git#clone-with-https" target="_blank" rel="noopener noreferrer">Clone with HTTPS</a>.') end end diff --git a/spec/lib/sidebars/user_settings/menus/password_menu_spec.rb b/spec/lib/sidebars/user_settings/menus/password_menu_spec.rb index 168019fea5d..83e47fd120a 100644 --- a/spec/lib/sidebars/user_settings/menus/password_menu_spec.rb +++ b/spec/lib/sidebars/user_settings/menus/password_menu_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe Sidebars::UserSettings::Menus::PasswordMenu, feature_category: :navigation do it_behaves_like 'User settings menu', - link: '/-/profile/password', + link: '/-/user_settings/password', title: _('Password'), icon: 'lock', active_routes: { controller: :passwords } diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 15bcbb3962c..79b663807b4 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -772,4 +772,24 @@ RSpec.describe Milestone, feature_category: :team_planning do it { is_expected.to eq(false) } end end + + describe '.with_ids_or_title' do + subject(:milestones) { described_class.with_ids_or_title(ids: ids, title: title) } + + let_it_be(:milestone1) { create(:milestone, title: 'Foo') } + let_it_be(:milestone2) { create(:milestone) } + + let(:ids) { [milestone1.id] } + let(:title) { milestone2.title } + + before do + # Milestones below should not be returned + create(:milestone, title: 'Bar') + create(:milestone, id: 10) + end + + it 'returns milestones with matching id or title' do + expect(milestones).to contain_exactly(milestone1, milestone2) + end + end end diff --git a/spec/models/namespace/package_setting_spec.rb b/spec/models/namespace/package_setting_spec.rb index e6096bc9267..f06490d7999 100644 --- a/spec/models/namespace/package_setting_spec.rb +++ b/spec/models/namespace/package_setting_spec.rb @@ -16,6 +16,9 @@ RSpec.describe Namespace::PackageSetting, feature_category: :package_registry do it { is_expected.to validate_inclusion_of(:nuget_duplicates_allowed).in_array([true, false]) } end + it { is_expected.to allow_value(true, false).for(:nuget_symbol_server_enabled) } + it { is_expected.not_to allow_value(nil).for(:nuget_symbol_server_enabled) } + describe 'regex values' do let_it_be(:package_settings) { create(:namespace_package_setting) } diff --git a/spec/requests/api/graphql/mutations/namespace/package_settings/update_spec.rb b/spec/requests/api/graphql/mutations/namespace/package_settings/update_spec.rb index 738dc3078e7..05c1a2d96d9 100644 --- a/spec/requests/api/graphql/mutations/namespace/package_settings/update_spec.rb +++ b/spec/requests/api/graphql/mutations/namespace/package_settings/update_spec.rb @@ -22,7 +22,8 @@ RSpec.describe 'Updating the package settings', feature_category: :package_regis npm_package_requests_forwarding: true, lock_npm_package_requests_forwarding: true, pypi_package_requests_forwarding: true, - lock_pypi_package_requests_forwarding: true + lock_pypi_package_requests_forwarding: true, + nuget_symbol_server_enabled: true } end @@ -42,6 +43,7 @@ RSpec.describe 'Updating the package settings', feature_category: :package_regis lockNpmPackageRequestsForwarding pypiPackageRequestsForwarding lockPypiPackageRequestsForwarding + nugetSymbolServerEnabled } errors QL @@ -70,6 +72,7 @@ RSpec.describe 'Updating the package settings', feature_category: :package_regis expect(package_settings_response['lockPypiPackageRequestsForwarding']).to eq(params[:lock_pypi_package_requests_forwarding]) expect(package_settings_response['npmPackageRequestsForwarding']).to eq(params[:npm_package_requests_forwarding]) expect(package_settings_response['lockNpmPackageRequestsForwarding']).to eq(params[:lock_npm_package_requests_forwarding]) + expect(package_settings_response['nugetSymbolServerEnabled']).to eq(params[:nuget_symbol_server_enabled]) end end @@ -111,7 +114,8 @@ RSpec.describe 'Updating the package settings', feature_category: :package_regis npm_package_requests_forwarding: nil, lock_npm_package_requests_forwarding: false, pypi_package_requests_forwarding: nil, - lock_pypi_package_requests_forwarding: false + lock_pypi_package_requests_forwarding: false, + nuget_symbol_server_enabled: false }, to: { maven_duplicates_allowed: false, maven_duplicate_exception_regex: 'foo-.*', @@ -124,7 +128,8 @@ RSpec.describe 'Updating the package settings', feature_category: :package_regis npm_package_requests_forwarding: true, lock_npm_package_requests_forwarding: true, pypi_package_requests_forwarding: true, - lock_pypi_package_requests_forwarding: true + lock_pypi_package_requests_forwarding: true, + nuget_symbol_server_enabled: true } it_behaves_like 'returning a success' diff --git a/spec/requests/legacy_routes_spec.rb b/spec/requests/legacy_routes_spec.rb index f1e93be5ce3..537ad4054a1 100644 --- a/spec/requests/legacy_routes_spec.rb +++ b/spec/requests/legacy_routes_spec.rb @@ -37,4 +37,20 @@ RSpec.describe "Legacy routes", type: :request, feature_category: :system_access get "/-/profile/applications" expect(response).to redirect_to('/-/user_settings/applications') end + + it "/-/profile/password/new" do + get "/-/profile/password/new" + expect(response).to redirect_to('/-/user_settings/password/new') + + get "/-/profile/password/new?abc=xyz" + expect(response).to redirect_to('/-/user_settings/password/new?abc=xyz') + end + + it "/-/profile/password/edit" do + get "/-/profile/password/edit" + expect(response).to redirect_to('/-/user_settings/password/edit') + + get "/-/profile/password/edit?abc=xyz" + expect(response).to redirect_to('/-/user_settings/password/edit?abc=xyz') + end end diff --git a/spec/requests/well_known_spec.rb b/spec/requests/well_known_spec.rb index 9db1f63690f..6236acac3ab 100644 --- a/spec/requests/well_known_spec.rb +++ b/spec/requests/well_known_spec.rb @@ -7,7 +7,7 @@ RSpec.describe 'well-known URLs', feature_category: :shared do it 'redirects to edit profile password path' do get('/.well-known/change-password') - expect(response).to redirect_to(edit_profile_password_path) + expect(response).to redirect_to(edit_user_settings_password_path) end end diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index 9edb9c842ab..8b54bc443da 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -122,7 +122,6 @@ end # profile_account GET /-/profile/account(.:format) profile#account # profile_history GET /-/profile/history(.:format) profile#history -# profile_password PUT /-/profile/password(.:format) profile#password_update # profile_token GET /-/profile/token(.:format) profile#token # profile GET /-/profile(.:format) profile#show # profile_update PUT /-/profile/update(.:format) profile#update diff --git a/spec/services/namespaces/package_settings/update_service_spec.rb b/spec/services/namespaces/package_settings/update_service_spec.rb index 8a4a51e409c..41f3499a1bb 100644 --- a/spec/services/namespaces/package_settings/update_service_spec.rb +++ b/spec/services/namespaces/package_settings/update_service_spec.rb @@ -45,7 +45,8 @@ RSpec.describe ::Namespaces::PackageSettings::UpdateService, feature_category: : npm_package_requests_forwarding: nil, lock_npm_package_requests_forwarding: false, pypi_package_requests_forwarding: nil, - lock_pypi_package_requests_forwarding: false + lock_pypi_package_requests_forwarding: false, + nuget_symbol_server_enabled: false }, to: { maven_duplicates_allowed: false, maven_duplicate_exception_regex: 'RELEASE', @@ -58,7 +59,8 @@ RSpec.describe ::Namespaces::PackageSettings::UpdateService, feature_category: : npm_package_requests_forwarding: true, lock_npm_package_requests_forwarding: true, pypi_package_requests_forwarding: true, - lock_pypi_package_requests_forwarding: true + lock_pypi_package_requests_forwarding: true, + nuget_symbol_server_enabled: true } it_behaves_like 'returning a success' @@ -109,7 +111,8 @@ RSpec.describe ::Namespaces::PackageSettings::UpdateService, feature_category: : npm_package_requests_forwarding: true, lock_npm_package_requests_forwarding: true, pypi_package_requests_forwarding: true, - lock_pypi_package_requests_forwarding: true + lock_pypi_package_requests_forwarding: true, + nuget_symbol_server_enabled: true } end diff --git a/spec/services/projects/group_links/create_service_spec.rb b/spec/services/projects/group_links/create_service_spec.rb index 6e3a8aa1733..6bc0b86545a 100644 --- a/spec/services/projects/group_links/create_service_spec.rb +++ b/spec/services/projects/group_links/create_service_spec.rb @@ -145,6 +145,15 @@ RSpec.describe Projects::GroupLinks::CreateService, '#execute', feature_category context 'when user does not have permissions to share the project with a group' do it_behaves_like 'not shareable' + + context 'when the user has less than MAINTAINER access in the project' do + before do + group.add_guest(user) + project.add_developer(user) + end + + it_behaves_like 'not shareable' + end end context 'when group is blank' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a3bc21ff11e..7317b512ae4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -38,7 +38,7 @@ require 'test_prof/factory_prof/nate_heckler' require 'parslet/rig/rspec' require 'axe-rspec' -require 'rspec_flaky' +require 'gitlab/rspec_flaky' rspec_profiling_is_configured = ENV['RSPEC_PROFILING_POSTGRES_URL'].present? || @@ -224,9 +224,9 @@ RSpec.configure do |config| config.exceptions_to_hard_fail = [DeprecationToolkitEnv::DeprecationBehaviors::SelectiveRaise::RaiseDisallowedDeprecation] end - if RspecFlaky::Config.generate_report? + if Gitlab::RspecFlaky::Config.generate_report? config.reporter.register_listener( - RspecFlaky::Listener.new, + Gitlab::RspecFlaky::Listener.new, :example_passed, :dump_summary) end diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml index 592d0cadaf5..81196fdcbfa 100644 --- a/spec/support/rspec_order_todo.yml +++ b/spec/support/rspec_order_todo.yml @@ -350,7 +350,6 @@ - './ee/spec/features/pending_project_memberships_spec.rb' - './ee/spec/features/profiles/account_spec.rb' - './ee/spec/features/profiles/billing_spec.rb' -- './ee/spec/features/profiles/password_spec.rb' - './ee/spec/features/profiles/user_visits_public_profile_spec.rb' - './ee/spec/features/projects/active_tabs_spec.rb' - './ee/spec/features/projects/audit_events_spec.rb' @@ -3724,7 +3723,6 @@ - './spec/features/profiles/gpg_keys_spec.rb' - './spec/features/profiles/keys_spec.rb' - './spec/features/profiles/oauth_applications_spec.rb' -- './spec/features/profiles/password_spec.rb' - './spec/features/profile_spec.rb' - './spec/features/profiles/two_factor_auths_spec.rb' - './spec/features/profiles/user_changes_notified_of_own_activity_spec.rb' diff --git a/spec/support/shared_examples/requests/api/discussions_shared_examples.rb b/spec/support/shared_examples/requests/api/discussions_shared_examples.rb index 2996c794e52..5cc87fb9654 100644 --- a/spec/support/shared_examples/requests/api/discussions_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/discussions_shared_examples.rb @@ -1,23 +1,29 @@ # frozen_string_literal: true RSpec.shared_examples 'with cross-reference system notes' do - let(:merge_request) { create(:merge_request) } - let(:project) { merge_request.project } - let(:new_merge_request) { create(:merge_request) } - let(:commit) { new_merge_request.project.commit } + let_it_be(:user) { create(:user) } + let_it_be(:pat) { create(:personal_access_token, user: user) } + let_it_be(:project) { create(:project, :small_repo) } + let_it_be(:project2) { create(:project, :small_repo) } + let_it_be(:project3) { create(:project, :small_repo) } + + let_it_be(:merge_request) { create(:merge_request, source_project: project) } + let_it_be(:new_merge_request) { create(:merge_request, source_project: project2) } + let_it_be(:hidden_merge_request) { create(:merge_request, source_project: project3) } + let!(:note) { create(:system_note, noteable: merge_request, project: project, note: cross_reference) } let!(:note_metadata) { create(:system_note_metadata, note: note, action: 'cross_reference') } let(:cross_reference) { "test commit #{commit.to_reference(project)}" } - let(:pat) { create(:personal_access_token, user: user) } + let(:commit) { new_merge_request.project.commit } - before do - project.add_developer(user) - new_merge_request.project.add_developer(user) + let!(:new_note) { create(:system_note, noteable: merge_request, project: project, note: hidden_cross_reference) } + let!(:new_note_metadata) { create(:system_note_metadata, note: new_note, action: 'cross_reference') } + let(:hidden_cross_reference) { "test commit #{hidden_commit.to_reference(project)}" } + let(:hidden_commit) { hidden_merge_request.project.commit } - hidden_merge_request = create(:merge_request) - new_cross_reference = "test commit #{hidden_merge_request.project.commit.to_reference(project)}" - new_note = create(:system_note, noteable: merge_request, project: project, note: new_cross_reference) - create(:system_note_metadata, note: new_note, action: 'cross_reference') + before_all do + project.add_developer(user) + project2.add_developer(user) end it 'returns only the note that the user should see' do diff --git a/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb b/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb index df7e36202ec..8281b7d4024 100644 --- a/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb @@ -754,48 +754,58 @@ RSpec.shared_examples 'nuget symbol file endpoint' do it { is_expected.to have_request_urgency(:low) } - context 'with valid target' do - it 'returns the symbol file' do - subject - - expect(response).to have_gitlab_http_status(:ok) - expect(response.media_type).to eq('application/octet-stream') - expect(response.body).to eq(symbol.file.read) - end - end - - context 'when nuget_symbolfiles_endpoint feature flag is disabled' do + context 'with nuget_symbol_server_enabled setting enabled' do before do - stub_feature_flags(nuget_symbolfiles_endpoint: false) + allow_next_instance_of(::Namespace::PackageSetting) do |setting| + allow(setting).to receive(:nuget_symbol_server_enabled).and_return(true) + end end - it_behaves_like 'returning response status', :not_found - end - - context 'when target does not exist' do - let(:target) { double(id: 1234567890) } + context 'with valid target' do + it 'returns the symbol file' do + subject - it_behaves_like 'returning response status', :not_found - end + expect(response).to have_gitlab_http_status(:ok) + expect(response.media_type).to eq('application/octet-stream') + expect(response.body).to eq(symbol.file.read) + end + end - context 'when target exists' do - context 'when symbol file does not exist' do - let(:filename) { 'non-existent-file.pdb' } - let(:signature) { 'non-existent-signature' } + context 'when target does not exist' do + let(:target) { double(id: 1234567890) } it_behaves_like 'returning response status', :not_found end - context 'when symbol file checksum does not match' do - let(:checksum) { 'non-matching-checksum' } + context 'when target exists' do + context 'when symbol file does not exist' do + let(:filename) { 'non-existent-file.pdb' } + let(:signature) { 'non-existent-signature' } - it_behaves_like 'returning response status', :not_found - end + it_behaves_like 'returning response status', :not_found + end + + context 'when symbol file checksum does not match' do + let(:checksum) { 'non-matching-checksum' } - context 'when symbol file checksum is missing' do - let(:headers) { {} } + it_behaves_like 'returning response status', :not_found + end + + context 'when symbol file checksum is missing' do + let(:headers) { {} } - it_behaves_like 'returning response status', :bad_request + it_behaves_like 'returning response status', :bad_request + end end end + + context 'with nuget_symbol_server_enabled setting disabled' do + before do + allow_next_instance_of(::Namespace::PackageSetting) do |setting| + allow(setting).to receive(:nuget_symbol_server_enabled).and_return(false) + end + end + + it_behaves_like 'returning response status', :forbidden + end end diff --git a/spec/support/shared_examples/services/namespace_package_settings_shared_examples.rb b/spec/support/shared_examples/services/namespace_package_settings_shared_examples.rb index 6f0fd1aa4ed..d288c74ae4b 100644 --- a/spec/support/shared_examples/services/namespace_package_settings_shared_examples.rb +++ b/spec/support/shared_examples/services/namespace_package_settings_shared_examples.rb @@ -11,6 +11,7 @@ RSpec.shared_examples 'updating the namespace package setting attributes' do |to .and change { namespace.package_settings.reload.generic_duplicate_exception_regex }.from(from[:generic_duplicate_exception_regex]).to(to[:generic_duplicate_exception_regex]) .and change { namespace.package_settings.reload.nuget_duplicates_allowed }.from(from[:nuget_duplicates_allowed]).to(to[:nuget_duplicates_allowed]) .and change { namespace.package_settings.reload.nuget_duplicate_exception_regex }.from(from[:nuget_duplicate_exception_regex]).to(to[:nuget_duplicate_exception_regex]) + .and change { namespace.package_settings.reload.nuget_symbol_server_enabled }.from(from[:nuget_symbol_server_enabled]).to(to[:nuget_symbol_server_enabled]) end end @@ -34,6 +35,7 @@ RSpec.shared_examples 'creating the namespace package setting' do expect(namespace.package_setting_relation.generic_duplicate_exception_regex).to eq(package_settings[:generic_duplicate_exception_regex]) expect(namespace.package_setting_relation.nuget_duplicates_allowed).to eq(package_settings[:nuget_duplicates_allowed]) expect(namespace.package_setting_relation.nuget_duplicate_exception_regex).to eq(package_settings[:nuget_duplicate_exception_regex]) + expect(namespace.package_setting_relation.nuget_symbol_server_enabled).to eq(package_settings[:nuget_symbol_server_enabled]) end it_behaves_like 'returning a success' |