diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-20 21:10:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-20 21:10:05 +0300 |
commit | cc4e1c884cd6b8782fb6a247d840a2d1c7f4603e (patch) | |
tree | 8a54c659b82873efafe04887708140785caea153 /spec | |
parent | 709948b7a69597b1efe24df9b0f388cc0b493dd9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
103 files changed, 507 insertions, 447 deletions
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index d0439a18158..55a73796d9d 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe RegistrationsController do +RSpec.describe RegistrationsController, feature_category: :users do include TermsHelper include FullNameHelper @@ -215,11 +215,18 @@ RSpec.describe RegistrationsController do property: member.id.to_s, user: member.reload.user ) + + expect_snowplow_event( + category: 'RegistrationsController', + action: 'create_user', + label: 'invited', + user: member.reload.user + ) end end context 'when member does not exist from the session key value' do - let(:originating_member_id) { -1 } + let(:originating_member_id) { nil } it 'does not track invite acceptance' do subject @@ -229,6 +236,13 @@ RSpec.describe RegistrationsController do action: 'accepted', label: 'invite_email' ) + + expect_snowplow_event( + category: 'RegistrationsController', + action: 'create_user', + label: 'signup', + user: member.reload.user + ) end end end diff --git a/spec/factories/packages/packages.rb b/spec/factories/packages/packages.rb index 1da4f0cedbc..3b7cd8298be 100644 --- a/spec/factories/packages/packages.rb +++ b/spec/factories/packages/packages.rb @@ -72,7 +72,7 @@ FactoryBot.define do transient do without_package_files { false } - file_metadatum_trait { :keep } + file_metadatum_trait { processing? ? :unknown : :keep } published_in { :create } end diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb index 32248ac1af2..c58ea0c8ce0 100644 --- a/spec/features/admin/admin_runners_spec.rb +++ b/spec/features/admin/admin_runners_spec.rb @@ -651,7 +651,7 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do visit edit_admin_runner_path(runner) end - it 'removed specific runner from project' do + it 'removed project runner from project' do within '[data-testid="assigned-projects"]' do click_on 'Disable' end diff --git a/spec/features/calendar_spec.rb b/spec/features/calendar_spec.rb index 2c5b7d66e2f..069c74dcd2a 100644 --- a/spec/features/calendar_spec.rb +++ b/spec/features/calendar_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Contributions Calendar', :js, feature_category: :users do +RSpec.describe 'Contributions Calendar', :js, feature_category: :user_profile do include MobileHelpers let(:user) { create(:user) } diff --git a/spec/features/dashboard/activity_spec.rb b/spec/features/dashboard/activity_spec.rb index edb3dacc2cc..ec6f67a59a8 100644 --- a/spec/features/dashboard/activity_spec.rb +++ b/spec/features/dashboard/activity_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard > Activity', feature_category: :users do +RSpec.describe 'Dashboard > Activity', feature_category: :user_profile do let(:user) { create(:user) } before do diff --git a/spec/features/dashboard/datetime_on_tooltips_spec.rb b/spec/features/dashboard/datetime_on_tooltips_spec.rb index 34f99765c29..a12772543e6 100644 --- a/spec/features/dashboard/datetime_on_tooltips_spec.rb +++ b/spec/features/dashboard/datetime_on_tooltips_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Tooltips on .timeago dates', :js, feature_category: :users do +RSpec.describe 'Tooltips on .timeago dates', :js, feature_category: :user_profile do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, name: 'test', namespace: user.namespace) } diff --git a/spec/features/dashboard/project_member_activity_index_spec.rb b/spec/features/dashboard/project_member_activity_index_spec.rb index 5bf1566fa31..c4dc78bf45b 100644 --- a/spec/features/dashboard/project_member_activity_index_spec.rb +++ b/spec/features/dashboard/project_member_activity_index_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Project member activity', :js, feature_category: :users do +RSpec.describe 'Project member activity', :js, feature_category: :user_profile do let(:user) { create(:user) } let(:project) { create(:project, :public, name: 'x', namespace: user.namespace) } diff --git a/spec/features/explore/topics_spec.rb b/spec/features/explore/topics_spec.rb index b5787a2dba8..dcccaea8c80 100644 --- a/spec/features/explore/topics_spec.rb +++ b/spec/features/explore/topics_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Explore Topics', feature_category: :users do +RSpec.describe 'Explore Topics', feature_category: :user_profile do context 'when no topics exist' do it 'renders empty message', :aggregate_failures do visit topics_explore_projects_path diff --git a/spec/features/explore/user_explores_projects_spec.rb b/spec/features/explore/user_explores_projects_spec.rb index f54a51c9ac9..14fddf5d84c 100644 --- a/spec/features/explore/user_explores_projects_spec.rb +++ b/spec/features/explore/user_explores_projects_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User explores projects', feature_category: :users do +RSpec.describe 'User explores projects', feature_category: :user_profile do context 'when some projects exist' do let_it_be(:archived_project) { create(:project, :archived) } let_it_be(:internal_project) { create(:project, :internal) } diff --git a/spec/features/file_uploads/user_avatar_spec.rb b/spec/features/file_uploads/user_avatar_spec.rb index 06501e09866..062c47d5310 100644 --- a/spec/features/file_uploads/user_avatar_spec.rb +++ b/spec/features/file_uploads/user_avatar_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Upload a user avatar', :js, feature_category: :users do +RSpec.describe 'Upload a user avatar', :js, feature_category: :user_profile do let_it_be(:user, reload: true) { create(:user) } let(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif') } diff --git a/spec/features/groups/clusters/user_spec.rb b/spec/features/groups/clusters/user_spec.rb index 3e565dd8eab..d876a5804bd 100644 --- a/spec/features/groups/clusters/user_spec.rb +++ b/spec/features/groups/clusters/user_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User Cluster', :js, feature_category: :users do +RSpec.describe 'User Cluster', :js, feature_category: :user_profile do include GoogleApi::CloudPlatformHelpers let(:group) { create(:group) } diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb index 87a65438768..e190dfda937 100644 --- a/spec/features/profile_spec.rb +++ b/spec/features/profile_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Profile account page', :js, feature_category: :users do +RSpec.describe 'Profile account page', :js, feature_category: :user_profile do include Spec::Support::Helpers::ModalHelpers let(:user) { create(:user) } diff --git a/spec/features/profiles/account_spec.rb b/spec/features/profiles/account_spec.rb index 82c45862e07..7e4308106be 100644 --- a/spec/features/profiles/account_spec.rb +++ b/spec/features/profiles/account_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Profile > Account', :js, feature_category: :users do +RSpec.describe 'Profile > Account', :js, feature_category: :user_profile do let(:user) { create(:user, username: 'foo') } before do diff --git a/spec/features/profiles/active_sessions_spec.rb b/spec/features/profiles/active_sessions_spec.rb index 5c20735cf35..0de4ad47f9a 100644 --- a/spec/features/profiles/active_sessions_spec.rb +++ b/spec/features/profiles/active_sessions_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state, feature_category: :users do +RSpec.describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state, feature_category: :user_profile do include Spec::Support::Helpers::ModalHelpers let(:user) do diff --git a/spec/features/profiles/chat_names_spec.rb b/spec/features/profiles/chat_names_spec.rb index 14fdb8ba56f..299ecdb6032 100644 --- a/spec/features/profiles/chat_names_spec.rb +++ b/spec/features/profiles/chat_names_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Profile > Chat', feature_category: :users do +RSpec.describe 'Profile > Chat', feature_category: :user_profile do let(:user) { create(:user) } let(:integration) { create(:integration) } diff --git a/spec/features/profiles/emails_spec.rb b/spec/features/profiles/emails_spec.rb index e8ea227c072..d00cef1f6f0 100644 --- a/spec/features/profiles/emails_spec.rb +++ b/spec/features/profiles/emails_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Profile > Emails', feature_category: :users do +RSpec.describe 'Profile > Emails', feature_category: :user_profile do let(:user) { create(:user) } let(:other_user) { create(:user) } diff --git a/spec/features/profiles/gpg_keys_spec.rb b/spec/features/profiles/gpg_keys_spec.rb index 1d014f983e7..0fc59f21489 100644 --- a/spec/features/profiles/gpg_keys_spec.rb +++ b/spec/features/profiles/gpg_keys_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Profile > GPG Keys', feature_category: :users do +RSpec.describe 'Profile > GPG Keys', feature_category: :user_profile do let(:user) { create(:user, email: GpgHelpers::User2.emails.first) } before do diff --git a/spec/features/profiles/keys_spec.rb b/spec/features/profiles/keys_spec.rb index 7a2a12d8dca..5acc59b190f 100644 --- a/spec/features/profiles/keys_spec.rb +++ b/spec/features/profiles/keys_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Profile > SSH Keys', feature_category: :users do +RSpec.describe 'Profile > SSH Keys', feature_category: :user_profile do let(:user) { create(:user) } before do diff --git a/spec/features/profiles/oauth_applications_spec.rb b/spec/features/profiles/oauth_applications_spec.rb index 80d05fd5cc7..d088f73f9df 100644 --- a/spec/features/profiles/oauth_applications_spec.rb +++ b/spec/features/profiles/oauth_applications_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Profile > Applications', feature_category: :users do +RSpec.describe 'Profile > Applications', feature_category: :user_profile do include Spec::Support::Helpers::ModalHelpers let(:user) { create(:user) } diff --git a/spec/features/profiles/password_spec.rb b/spec/features/profiles/password_spec.rb index b324ee17873..c0c573d2f20 100644 --- a/spec/features/profiles/password_spec.rb +++ b/spec/features/profiles/password_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Profile > Password', feature_category: :users do +RSpec.describe 'Profile > Password', feature_category: :user_profile do let(:user) { create(:user) } def fill_passwords(password, confirmation) diff --git a/spec/features/profiles/personal_access_tokens_spec.rb b/spec/features/profiles/personal_access_tokens_spec.rb index 3087d7ff296..a050e87241b 100644 --- a/spec/features/profiles/personal_access_tokens_spec.rb +++ b/spec/features/profiles/personal_access_tokens_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Profile > Personal Access Tokens', :js, feature_category: :users do +RSpec.describe 'Profile > Personal Access Tokens', :js, feature_category: :user_profile do include Spec::Support::Helpers::ModalHelpers include Spec::Support::Helpers::AccessTokenHelpers diff --git a/spec/features/profiles/two_factor_auths_spec.rb b/spec/features/profiles/two_factor_auths_spec.rb index 8dddaad11c3..e8ff8416722 100644 --- a/spec/features/profiles/two_factor_auths_spec.rb +++ b/spec/features/profiles/two_factor_auths_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Two factor auths', feature_category: :users do +RSpec.describe 'Two factor auths', feature_category: :user_profile do include Spec::Support::Helpers::ModalHelpers context 'when signed in' do diff --git a/spec/features/profiles/user_changes_notified_of_own_activity_spec.rb b/spec/features/profiles/user_changes_notified_of_own_activity_spec.rb index 197a33c355d..89887cb4772 100644 --- a/spec/features/profiles/user_changes_notified_of_own_activity_spec.rb +++ b/spec/features/profiles/user_changes_notified_of_own_activity_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Profile > Notifications > User changes notified_of_own_activity setting', :js, -feature_category: :users do +feature_category: :user_profile do let(:user) { create(:user) } before do diff --git a/spec/features/profiles/user_edit_preferences_spec.rb b/spec/features/profiles/user_edit_preferences_spec.rb index 1a231f1d269..f7a9850355a 100644 --- a/spec/features/profiles/user_edit_preferences_spec.rb +++ b/spec/features/profiles/user_edit_preferences_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User edit preferences profile', :js, feature_category: :users do +RSpec.describe 'User edit preferences profile', :js, feature_category: :user_profile do include StubLanguagesTranslationPercentage # Empty value doesn't change the levels diff --git a/spec/features/profiles/user_edit_profile_spec.rb b/spec/features/profiles/user_edit_profile_spec.rb index 67604292090..3819723cc09 100644 --- a/spec/features/profiles/user_edit_profile_spec.rb +++ b/spec/features/profiles/user_edit_profile_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User edit profile', feature_category: :users do +RSpec.describe 'User edit profile', feature_category: :user_profile do include Spec::Support::Helpers::Features::NotesHelpers let_it_be(:user) { create(:user) } diff --git a/spec/features/profiles/user_manages_applications_spec.rb b/spec/features/profiles/user_manages_applications_spec.rb index 179da61b8ed..e3c4a797431 100644 --- a/spec/features/profiles/user_manages_applications_spec.rb +++ b/spec/features/profiles/user_manages_applications_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User manages applications', feature_category: :users do +RSpec.describe 'User manages applications', feature_category: :user_profile do let_it_be(:user) { create(:user) } let_it_be(:new_application_path) { applications_profile_path } let_it_be(:index_path) { oauth_applications_path } diff --git a/spec/features/profiles/user_manages_emails_spec.rb b/spec/features/profiles/user_manages_emails_spec.rb index 16a9fbc2f47..b875dfec217 100644 --- a/spec/features/profiles/user_manages_emails_spec.rb +++ b/spec/features/profiles/user_manages_emails_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User manages emails', feature_category: :users do +RSpec.describe 'User manages emails', feature_category: :user_profile do let(:user) { create(:user) } let(:other_user) { create(:user) } diff --git a/spec/features/profiles/user_search_settings_spec.rb b/spec/features/profiles/user_search_settings_spec.rb index 09ee8ddeaab..932ea11075a 100644 --- a/spec/features/profiles/user_search_settings_spec.rb +++ b/spec/features/profiles/user_search_settings_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User searches their settings', :js, feature_category: :users do +RSpec.describe 'User searches their settings', :js, feature_category: :user_profile do let_it_be(:user) { create(:user) } before do diff --git a/spec/features/profiles/user_visits_notifications_tab_spec.rb b/spec/features/profiles/user_visits_notifications_tab_spec.rb index d212982f4e3..1295a0b6150 100644 --- a/spec/features/profiles/user_visits_notifications_tab_spec.rb +++ b/spec/features/profiles/user_visits_notifications_tab_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User visits the notifications tab', :js, feature_category: :users do +RSpec.describe 'User visits the notifications tab', :js, feature_category: :user_profile do let(:project) { create(:project) } let(:user) { create(:user) } diff --git a/spec/features/profiles/user_visits_profile_account_page_spec.rb b/spec/features/profiles/user_visits_profile_account_page_spec.rb index 1cf34478ecf..8ff9cbc242e 100644 --- a/spec/features/profiles/user_visits_profile_account_page_spec.rb +++ b/spec/features/profiles/user_visits_profile_account_page_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User visits the profile account page', feature_category: :users do +RSpec.describe 'User visits the profile account page', feature_category: :user_profile do let(:user) { create(:user) } before do diff --git a/spec/features/profiles/user_visits_profile_authentication_log_spec.rb b/spec/features/profiles/user_visits_profile_authentication_log_spec.rb index 726cca4a4bd..90f24c5b866 100644 --- a/spec/features/profiles/user_visits_profile_authentication_log_spec.rb +++ b/spec/features/profiles/user_visits_profile_authentication_log_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User visits the authentication log', feature_category: :users do +RSpec.describe 'User visits the authentication log', feature_category: :user_profile do let(:user) { create(:user) } context 'when user signed in' do diff --git a/spec/features/profiles/user_visits_profile_preferences_page_spec.rb b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb index e3940973c46..d690589b893 100644 --- a/spec/features/profiles/user_visits_profile_preferences_page_spec.rb +++ b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User visits the profile preferences page', :js, feature_category: :users do +RSpec.describe 'User visits the profile preferences page', :js, feature_category: :user_profile do include ListboxHelpers let(:user) { create(:user) } diff --git a/spec/features/profiles/user_visits_profile_spec.rb b/spec/features/profiles/user_visits_profile_spec.rb index 7fca0f24deb..8ea7ad206c5 100644 --- a/spec/features/profiles/user_visits_profile_spec.rb +++ b/spec/features/profiles/user_visits_profile_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User visits their profile', feature_category: :users do +RSpec.describe 'User visits their profile', feature_category: :user_profile do let_it_be_with_refind(:user) { create(:user) } before do diff --git a/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb b/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb index 8467e9abeaf..547e47ead77 100644 --- a/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb +++ b/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User visits the profile SSH keys page', feature_category: :users do +RSpec.describe 'User visits the profile SSH keys page', feature_category: :user_profile do let(:user) { create(:user) } before do diff --git a/spec/features/runners_spec.rb b/spec/features/runners_spec.rb index e7c2452af93..b2ddf427c0d 100644 --- a/spec/features/runners_spec.rb +++ b/spec/features/runners_spec.rb @@ -64,10 +64,10 @@ RSpec.describe 'Runners', feature_category: :runner_fleet do context 'when a project_type runner is activated on the project' do let_it_be(:project_runner) { create(:ci_runner, :project, projects: [project]) } - it 'user sees the specific runner' do + it 'user sees the project runner' do visit project_runners_path(project) - within '.activated-specific-runners' do + within '[data-testid="assigned_project_runners"]' do expect(page).to have_content(project_runner.display_name) end @@ -76,30 +76,30 @@ RSpec.describe 'Runners', feature_category: :runner_fleet do expect(page).to have_content(project_runner.platform) end - it 'user can pause and resume the specific runner' do + it 'user can pause and resume the project runner' do visit project_runners_path(project) - within '.activated-specific-runners' do + within '[data-testid="assigned_project_runners"]' do expect(page).to have_link('Pause') end click_on 'Pause' - within '.activated-specific-runners' do + within '[data-testid="assigned_project_runners"]' do expect(page).to have_link('Resume') end click_on 'Resume' - within '.activated-specific-runners' do + within '[data-testid="assigned_project_runners"]' do expect(page).to have_link('Pause') end end - it 'user removes an activated specific runner if this is last project for that runners' do + it 'user removes an activated project runner if this is last project for that runners' do visit project_runners_path(project) - within '.activated-specific-runners' do + within '[data-testid="assigned_project_runners"]' do click_on 'Remove runner' end @@ -109,7 +109,7 @@ RSpec.describe 'Runners', feature_category: :runner_fleet do it 'user edits the runner to be protected' do visit project_runners_path(project) - within '.activated-specific-runners' do + within '[data-testid="assigned_project_runners"]' do first('[data-testid="edit-runner-link"]').click end @@ -129,7 +129,7 @@ RSpec.describe 'Runners', feature_category: :runner_fleet do it 'user edits runner not to run untagged jobs' do visit project_runners_path(project) - within '.activated-specific-runners' do + within '[data-testid="assigned_project_runners"]' do first('[data-testid="edit-runner-link"]').click end @@ -189,7 +189,7 @@ RSpec.describe 'Runners', feature_category: :runner_fleet do end end - context 'when a specific runner exists in another project' do + context 'when a project runner exists in another project' do let(:another_project) { create(:project) } let!(:project_runner) { create(:ci_runner, :project, projects: [another_project]) } @@ -197,20 +197,20 @@ RSpec.describe 'Runners', feature_category: :runner_fleet do another_project.add_maintainer(user) end - it 'user enables and disables a specific runner' do + it 'user enables and disables a project runner' do visit project_runners_path(project) - within '.available-specific-runners' do + within '[data-testid="available_project_runners"]' do click_on 'Enable for this project' end - expect(page.find('.activated-specific-runners')).to have_content(project_runner.display_name) + expect(page.find('[data-testid="assigned_project_runners"]')).to have_content(project_runner.display_name) - within '.activated-specific-runners' do + within '[data-testid="assigned_project_runners"]' do click_on 'Disable for this project' end - expect(page.find('.available-specific-runners')).to have_content(project_runner.display_name) + expect(page.find('[data-testid="available_project_runners"]')).to have_content(project_runner.display_name) end end diff --git a/spec/features/uploads/user_uploads_avatar_to_group_spec.rb b/spec/features/uploads/user_uploads_avatar_to_group_spec.rb index 78cede77fea..02e98905662 100644 --- a/spec/features/uploads/user_uploads_avatar_to_group_spec.rb +++ b/spec/features/uploads/user_uploads_avatar_to_group_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User uploads avatar to group', feature_category: :users do +RSpec.describe 'User uploads avatar to group', feature_category: :user_profile do it 'they see the new avatar' do user = create(:user) group = create(:group) diff --git a/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb b/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb index fb62b5eadc5..f1023f17d3e 100644 --- a/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb +++ b/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User uploads avatar to profile', feature_category: :users do +RSpec.describe 'User uploads avatar to profile', feature_category: :user_profile do let!(:user) { create(:user) } let(:avatar_file_path) { Rails.root.join('spec', 'fixtures', 'dk.png') } diff --git a/spec/features/users/add_email_to_existing_account_spec.rb b/spec/features/users/add_email_to_existing_account_spec.rb index 8c4e68c454f..ea39e5c5a49 100644 --- a/spec/features/users/add_email_to_existing_account_spec.rb +++ b/spec/features/users/add_email_to_existing_account_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'AdditionalEmailToExistingAccount', feature_category: :users do +RSpec.describe 'AdditionalEmailToExistingAccount', feature_category: :user_profile do describe 'add secondary email associated with account' do let_it_be(:user) { create(:user) } let_it_be(:email) { create(:email, user: user) } diff --git a/spec/features/users/overview_spec.rb b/spec/features/users/overview_spec.rb index 489e7d61ff9..6c6c5ca2b27 100644 --- a/spec/features/users/overview_spec.rb +++ b/spec/features/users/overview_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Overview tab on a user profile', :js, feature_category: :users do +RSpec.describe 'Overview tab on a user profile', :js, feature_category: :user_profile do let(:user) { create(:user) } let(:contributed_project) { create(:project, :public, :repository) } diff --git a/spec/features/users/rss_spec.rb b/spec/features/users/rss_spec.rb index a2604cd298a..bc37c9941ce 100644 --- a/spec/features/users/rss_spec.rb +++ b/spec/features/users/rss_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User RSS', feature_category: :users do +RSpec.describe 'User RSS', feature_category: :user_profile do let(:user) { create(:user) } let(:path) { user_path(create(:user)) } diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb index 318dd688fa4..17c33398c0e 100644 --- a/spec/features/users/show_spec.rb +++ b/spec/features/users/show_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User page', feature_category: :users do +RSpec.describe 'User page', feature_category: :user_profile do include ExternalAuthorizationServiceHelpers let_it_be(:user) { create(:user, bio: '<b>Lorem</b> <i>ipsum</i> dolor sit <a href="https://example.com">amet</a>') } diff --git a/spec/features/users/signup_spec.rb b/spec/features/users/signup_spec.rb index 1057ae48c7d..11ff318c346 100644 --- a/spec/features/users/signup_spec.rb +++ b/spec/features/users/signup_spec.rb @@ -44,7 +44,7 @@ RSpec.shared_examples 'Signup name validation' do |field, max_length, label| end end -RSpec.describe 'Signup', feature_category: :users do +RSpec.describe 'Signup', feature_category: :user_profile do include TermsHelper let(:new_user) { build_stubbed(:user) } diff --git a/spec/features/users/terms_spec.rb b/spec/features/users/terms_spec.rb index 7d2137b81b8..5c61843e558 100644 --- a/spec/features/users/terms_spec.rb +++ b/spec/features/users/terms_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Users > Terms', :js, feature_category: :users do +RSpec.describe 'Users > Terms', :js, feature_category: :user_profile do include TermsHelper let!(:term) { create(:term, terms: 'By accepting, you promise to be nice!') } diff --git a/spec/frontend/groups/components/app_spec.js b/spec/frontend/groups/components/app_spec.js index 140609161d4..13c9f206033 100644 --- a/spec/frontend/groups/components/app_spec.js +++ b/spec/frontend/groups/components/app_spec.js @@ -11,6 +11,7 @@ import eventHub from '~/groups/event_hub'; import GroupsService from '~/groups/service/groups_service'; import GroupsStore from '~/groups/store/groups_store'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_FORBIDDEN } from '~/lib/utils/http_status'; import * as urlUtilities from '~/lib/utils/url_utility'; import setWindowLocation from 'helpers/set_window_location_helper'; @@ -336,7 +337,7 @@ describe('AppComponent', () => { it('should show appropriate error flash message if request forbids to leave group', () => { const message = 'Failed to leave the group. Please make sure you are not the only owner.'; - jest.spyOn(vm.service, 'leaveGroup').mockRejectedValue({ status: 403 }); + jest.spyOn(vm.service, 'leaveGroup').mockRejectedValue({ status: HTTP_STATUS_FORBIDDEN }); jest.spyOn(vm.store, 'removeGroup'); vm.leaveGroup(childGroupItem, groupItem); diff --git a/spec/frontend/pages/admin/projects/components/namespace_select_spec.js b/spec/frontend/pages/admin/projects/components/namespace_select_spec.js index 909349569a8..834d14e0fb3 100644 --- a/spec/frontend/pages/admin/projects/components/namespace_select_spec.js +++ b/spec/frontend/pages/admin/projects/components/namespace_select_spec.js @@ -1,99 +1,142 @@ -import { mount } from '@vue/test-utils'; +import { GlCollapsibleListbox } from '@gitlab/ui'; import { nextTick } from 'vue'; +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; +import waitForPromises from 'helpers/wait_for_promises'; import Api from '~/api'; import NamespaceSelect from '~/pages/admin/projects/components/namespace_select.vue'; -describe('Dropdown select component', () => { +const TEST_USER_NAMESPACE = { id: 10, kind: 'user', full_path: 'Administrator' }; +const TEST_GROUP_NAMESPACE = { id: 20, kind: 'group', full_path: 'GitLab Org' }; + +describe('NamespaceSelect', () => { let wrapper; - const mountDropdown = (propsData) => { - wrapper = mount(NamespaceSelect, { propsData }); + const createComponent = (propsData) => { + wrapper = shallowMountExtended(NamespaceSelect, { propsData }); }; - const findDropdownToggle = () => wrapper.find('button.dropdown-toggle'); - const findNamespaceInput = () => wrapper.find('[data-testid="hidden-input"]'); - const findFilterInput = () => wrapper.find('.namespace-search-box input'); - const findDropdownOption = (match) => { - const buttons = wrapper - .findAll('button.dropdown-item') - .filter((node) => node.text().match(match)); - return buttons.length ? buttons.at(0) : buttons; - }; + const findListbox = () => wrapper.findComponent(GlCollapsibleListbox); + const findNamespaceInput = () => wrapper.findByTestId('hidden-input'); - const setFieldValue = async (field, value) => { - await field.setValue(value); - field.trigger('blur'); + const search = async (searchString) => { + findListbox().vm.$emit('search', searchString); + await waitForPromises(); }; beforeEach(() => { setHTMLFixture('<div class="test-container"></div>'); - jest.spyOn(Api, 'namespaces').mockImplementation((_, callback) => - callback([ - { id: 10, kind: 'user', full_path: 'Administrator' }, - { id: 20, kind: 'group', full_path: 'GitLab Org' }, - ]), - ); + jest + .spyOn(Api, 'namespaces') + .mockImplementation((_, callback) => callback([TEST_USER_NAMESPACE, TEST_GROUP_NAMESPACE])); }); afterEach(() => { resetHTMLFixture(); }); - it('creates a hidden input if fieldName is provided', () => { - mountDropdown({ fieldName: 'namespace-input' }); + describe('on mount', () => { + beforeEach(() => { + createComponent(); + }); + + it('does not show hidden input', () => { + expect(findNamespaceInput().exists()).toBe(false); + }); + + it('sets appropriate props', async () => { + expect(findListbox().props()).toMatchObject({ + items: [ + { text: 'user: Administrator', value: '10' }, + { text: 'group: GitLab Org', value: '20' }, + ], + headerText: NamespaceSelect.i18n.headerText, + resetButtonLabel: NamespaceSelect.i18n.reset, + toggleText: 'Namespace', + searchPlaceholder: NamespaceSelect.i18n.searchPlaceholder, + searching: false, + searchable: true, + }); + }); + }); + + it('with fieldName, shows hidden input', () => { + createComponent({ fieldName: 'namespace-input' }); expect(findNamespaceInput().exists()).toBe(true); expect(findNamespaceInput().attributes('name')).toBe('namespace-input'); }); - describe('clicking dropdown options', () => { + describe('select', () => { + describe.each` + selectId | expectToggleText + ${String(TEST_USER_NAMESPACE.id)} | ${`user: ${TEST_USER_NAMESPACE.full_path}`} + ${String(TEST_GROUP_NAMESPACE.id)} | ${`group: ${TEST_GROUP_NAMESPACE.full_path}`} + `('clicking listbox options (selectId=$selectId)', ({ selectId, expectToggleText }) => { + beforeEach(async () => { + createComponent({ fieldName: 'namespace-input' }); + findListbox().vm.$emit('select', selectId); + await nextTick(); + }); + + it('updates hidden field', () => { + expect(findNamespaceInput().attributes('value')).toBe(selectId); + }); + + it('updates the listbox value', async () => { + expect(findListbox().props()).toMatchObject({ + selected: selectId, + toggleText: expectToggleText, + }); + }); + + it('triggers a setNamespace event upon selection', () => { + expect(wrapper.emitted('setNamespace')).toEqual([[selectId]]); + }); + }); + }); + + describe('search', () => { it('retrieves namespaces based on filter query', async () => { - mountDropdown(); + createComponent(); - await setFieldValue(findFilterInput(), 'test'); + // Add space to assert that `?.trim` is called + await search('test '); expect(Api.namespaces).toHaveBeenCalledWith('test', expect.anything()); }); - it('updates the dropdown value based upon selection', async () => { - mountDropdown({ fieldName: 'namespace-input' }); - - // wait for dropdown options to populate - await nextTick(); - - expect(findDropdownOption('user: Administrator').exists()).toBe(true); - expect(findDropdownOption('group: GitLab Org').exists()).toBe(true); - expect(findDropdownOption('group: Foobar').exists()).toBe(false); + it('when not found, does not change the placeholder text', async () => { + createComponent({ + origSelectedId: String(TEST_USER_NAMESPACE.id), + origSelectedText: `user: ${TEST_USER_NAMESPACE.full_path}`, + }); - findDropdownOption('user: Administrator').trigger('click'); - await nextTick(); + await search('not exist'); - expect(findNamespaceInput().attributes('value')).toBe('10'); - expect(findDropdownToggle().text()).toBe('user: Administrator'); + expect(findListbox().props()).toMatchObject({ + selected: String(TEST_USER_NAMESPACE.id), + toggleText: `user: ${TEST_USER_NAMESPACE.full_path}`, + }); }); + }); - it('triggers a setNamespace event upon selection', async () => { - mountDropdown(); - - // wait for dropdown options to populate - await nextTick(); - - findDropdownOption('group: GitLab Org').trigger('click'); - - expect(wrapper.emitted('setNamespace')).toHaveLength(1); - expect(wrapper.emitted('setNamespace')[0][0]).toBe(20); + describe('reset', () => { + beforeEach(() => { + createComponent(); + findListbox().vm.$emit('reset'); }); - it('displays "Any Namespace" option when showAny prop provided', () => { - mountDropdown({ showAny: true }); - expect(wrapper.text()).toContain('Any namespace'); + it('updates the listbox value', () => { + expect(findListbox().props()).toMatchObject({ + selected: null, + toggleText: 'Namespace', + }); }); - it('does not display "Any Namespace" option when showAny prop not provided', () => { - mountDropdown(); - expect(wrapper.text()).not.toContain('Any namespace'); + it('triggers a setNamespace event upon reset', () => { + expect(wrapper.emitted('setNamespace')).toEqual([[null]]); }); }); }); diff --git a/spec/graphql/mutations/achievements/create_spec.rb b/spec/graphql/mutations/achievements/create_spec.rb index 4bad6164314..12b8ff67549 100644 --- a/spec/graphql/mutations/achievements/create_spec.rb +++ b/spec/graphql/mutations/achievements/create_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Mutations::Achievements::Create, feature_category: :users do +RSpec.describe Mutations::Achievements::Create, feature_category: :user_profile do include GraphqlHelpers let_it_be(:user) { create(:user) } diff --git a/spec/graphql/types/achievements/achievement_type_spec.rb b/spec/graphql/types/achievements/achievement_type_spec.rb index 5c98753ac66..d8cd52f78d7 100644 --- a/spec/graphql/types/achievements/achievement_type_spec.rb +++ b/spec/graphql/types/achievements/achievement_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GitlabSchema.types['Achievement'], feature_category: :users do +RSpec.describe GitlabSchema.types['Achievement'], feature_category: :user_profile do include GraphqlHelpers let(:fields) do diff --git a/spec/graphql/types/ci/job_type_spec.rb b/spec/graphql/types/ci/job_type_spec.rb index ce1558c4097..f2a53b373ac 100644 --- a/spec/graphql/types/ci/job_type_spec.rb +++ b/spec/graphql/types/ci/job_type_spec.rb @@ -32,6 +32,7 @@ RSpec.describe Types::Ci::JobType do pipeline playable previousStageJobsOrNeeds + project queued_at queued_duration refName diff --git a/spec/graphql/types/user_type_spec.rb b/spec/graphql/types/user_type_spec.rb index 45cb960cf20..096341b1ba9 100644 --- a/spec/graphql/types/user_type_spec.rb +++ b/spec/graphql/types/user_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GitlabSchema.types['User'], feature_category: :users do +RSpec.describe GitlabSchema.types['User'], feature_category: :user_profile do specify { expect(described_class.graphql_name).to eq('User') } specify do diff --git a/spec/graphql/types/users/email_type_spec.rb b/spec/graphql/types/users/email_type_spec.rb index fb484915428..107bbf81e98 100644 --- a/spec/graphql/types/users/email_type_spec.rb +++ b/spec/graphql/types/users/email_type_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -RSpec.describe GitlabSchema.types['Email'], feature_category: :users do +RSpec.describe GitlabSchema.types['Email'], feature_category: :user_profile do it 'has the correct fields' do expected_fields = [ :id, diff --git a/spec/graphql/types/users/namespace_commit_email_type_spec.rb b/spec/graphql/types/users/namespace_commit_email_type_spec.rb index ccab881676e..27e50f7285e 100644 --- a/spec/graphql/types/users/namespace_commit_email_type_spec.rb +++ b/spec/graphql/types/users/namespace_commit_email_type_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -RSpec.describe GitlabSchema.types['NamespaceCommitEmail'], feature_category: :users do +RSpec.describe GitlabSchema.types['NamespaceCommitEmail'], feature_category: :user_profile do it 'has the correct fields' do expected_fields = [ :id, diff --git a/spec/lib/gitlab/contributions_calendar_spec.rb b/spec/lib/gitlab/contributions_calendar_spec.rb index 3736914669a..326e27fa716 100644 --- a/spec/lib/gitlab/contributions_calendar_spec.rb +++ b/spec/lib/gitlab/contributions_calendar_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Gitlab::ContributionsCalendar, feature_category: :users do +RSpec.describe Gitlab::ContributionsCalendar, feature_category: :user_profile do let_it_be_with_reload(:contributor) { create(:user) } let_it_be_with_reload(:user) { create(:user) } let(:travel_time) { nil } diff --git a/spec/lib/gitlab/etag_caching/middleware_spec.rb b/spec/lib/gitlab/etag_caching/middleware_spec.rb index da5eaf2e4ab..81751511270 100644 --- a/spec/lib/gitlab/etag_caching/middleware_spec.rb +++ b/spec/lib/gitlab/etag_caching/middleware_spec.rb @@ -123,7 +123,15 @@ RSpec.describe Gitlab::EtagCaching::Middleware, :clean_gitlab_redis_shared_state format: :html, method: 'GET', path: enabled_path, - status: status_code + status: status_code, + request_urgency: :low, + target_duration_s: 5, + metadata: a_hash_including( + { + 'meta.caller_id' => 'Projects::NotesController#index', + 'meta.feature_category' => 'team_planning' + } + ) } end @@ -172,10 +180,11 @@ RSpec.describe Gitlab::EtagCaching::Middleware, :clean_gitlab_redis_shared_state expect(headers).to include('X-Gitlab-From-Cache' => 'true') end - it "pushes route's feature category to the context" do + it "pushes expected information in to the context" do expect(Gitlab::ApplicationContext).to receive(:push).with( feature_category: 'team_planning', - caller_id: 'Projects::NotesController#index' + caller_id: 'Projects::NotesController#index', + remote_ip: '127.0.0.1' ) _, _, _ = middleware.call(build_request(path, if_none_match)) @@ -291,7 +300,8 @@ RSpec.describe Gitlab::EtagCaching::Middleware, :clean_gitlab_redis_shared_state { 'PATH_INFO' => path, 'HTTP_IF_NONE_MATCH' => if_none_match, 'rack.input' => '', - 'REQUEST_METHOD' => 'GET' } + 'REQUEST_METHOD' => 'GET', + 'REMOTE_ADDR' => '127.0.0.1' } end def payload_for(event) diff --git a/spec/lib/gitlab/etag_caching/router/graphql_spec.rb b/spec/lib/gitlab/etag_caching/router/graphql_spec.rb index 792f02f8cda..fae468ab84f 100644 --- a/spec/lib/gitlab/etag_caching/router/graphql_spec.rb +++ b/spec/lib/gitlab/etag_caching/router/graphql_spec.rb @@ -18,6 +18,12 @@ RSpec.describe Gitlab::EtagCaching::Router::Graphql do end end + it 'applies the default urgency for every route', :aggregate_failures do + described_class::ROUTES.each do |route| + expect(route.urgency).to be(Gitlab::EndpointAttributes::DEFAULT_URGENCY) + end + end + def match_route(path, header) described_class.match( double(path_info: path, diff --git a/spec/lib/gitlab/etag_caching/router/rails_spec.rb b/spec/lib/gitlab/etag_caching/router/rails_spec.rb index da6c11e3cb1..251f634aac1 100644 --- a/spec/lib/gitlab/etag_caching/router/rails_spec.rb +++ b/spec/lib/gitlab/etag_caching/router/rails_spec.rb @@ -109,17 +109,23 @@ RSpec.describe Gitlab::EtagCaching::Router::Rails do it 'has a valid feature category for every route', :aggregate_failures do feature_categories = Gitlab::FeatureCategories.default.categories - described_class::ROUTES.each do |route| + described_class.all_routes.each do |route| expect(feature_categories).to include(route.feature_category), "#{route.name} has a category of #{route.feature_category}, which is not valid" end end it 'has a caller_id for every route', :aggregate_failures do - described_class::ROUTES.each do |route| + described_class.all_routes.each do |route| expect(route.caller_id).to include('#'), "#{route.name} has caller_id #{route.caller_id}, which is not valid" end end + it 'has an urgency for every route', :aggregate_failures do + described_class.all_routes.each do |route| + expect(route.urgency).to be_an_instance_of(Gitlab::EndpointAttributes::Config::RequestUrgency) + end + end + def match_route(path) described_class.match(double(path_info: path)) end diff --git a/spec/lib/gitlab/etag_caching/router_spec.rb b/spec/lib/gitlab/etag_caching/router_spec.rb index 8d2183bc03d..bc07f9a99a5 100644 --- a/spec/lib/gitlab/etag_caching/router_spec.rb +++ b/spec/lib/gitlab/etag_caching/router_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Gitlab::EtagCaching::Router do expect(result).to be_present expect(result.name).to eq 'project_pipelines' expect(result.router).to eq Gitlab::EtagCaching::Router::Rails + expect(result.urgency).to eq Projects::PipelinesController.urgency_for_action(:index) end end @@ -21,6 +22,7 @@ RSpec.describe Gitlab::EtagCaching::Router do expect(result).to be_present expect(result.name).to eq 'pipelines_graph' expect(result.router).to eq Gitlab::EtagCaching::Router::Graphql + expect(result.urgency).to eq ::Gitlab::EndpointAttributes::DEFAULT_URGENCY end it 'matches pipeline sha endpoint' do diff --git a/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb b/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb index 61c690b85e9..d6644bc12d2 100644 --- a/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb +++ b/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb @@ -415,6 +415,35 @@ RSpec.describe Gitlab::Metrics::RequestsRackMiddleware, :aggregate_failures, fea end end + context 'A request with urgency set on the env (from ETag-caching)' do + let(:env) do + { described_class::REQUEST_URGENCY_KEY => Gitlab::EndpointAttributes::Config::REQUEST_URGENCIES[:medium], + 'REQUEST_METHOD' => 'GET' } + end + + it 'records the request with the correct urgency' do + allow(Gitlab::Metrics::System).to receive(:monotonic_time).and_return(100, 100.1) + expect(Gitlab::Metrics::RailsSlis.request_apdex).to receive(:increment).with( + labels: { + feature_category: 'unknown', + endpoint_id: 'unknown', + request_urgency: :medium + }, + success: true + ) + expect(Gitlab::Metrics::RailsSlis.request_error_rate).to receive(:increment).with( + labels: { + feature_category: 'unknown', + endpoint_id: 'unknown', + request_urgency: :medium + }, + error: false + ) + + subject.call(env) + end + end + context 'An unknown request' do let(:env) do { 'REQUEST_METHOD' => 'GET' } diff --git a/spec/lib/gitlab/redis/duplicate_jobs_spec.rb b/spec/lib/gitlab/redis/duplicate_jobs_spec.rb deleted file mode 100644 index 4d46a567032..00000000000 --- a/spec/lib/gitlab/redis/duplicate_jobs_spec.rb +++ /dev/null @@ -1,84 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Gitlab::Redis::DuplicateJobs do - # Note: this is a pseudo-store in front of `SharedState`, meant only as a tool - # to move away from `Sidekiq.redis` for duplicate job data. Thus, we use the - # same store configuration as the former. - let(:instance_specific_config_file) { "config/redis.shared_state.yml" } - let(:environment_config_file_name) { "GITLAB_REDIS_SHARED_STATE_CONFIG_FILE" } - - include_examples "redis_shared_examples" - - describe '#pool' do - subject { described_class.pool } - - around do |example| - clear_pool - example.run - ensure - clear_pool - end - - context 'store connection settings' do - let(:config_new_format_host) { "spec/fixtures/config/redis_new_format_host.yml" } - let(:config_new_format_socket) { "spec/fixtures/config/redis_new_format_socket.yml" } - - before do - allow(Gitlab::Redis::SharedState).to receive(:config_file_name).and_return(config_new_format_host) - allow(Gitlab::Redis::Queues).to receive(:config_file_name).and_return(config_new_format_socket) - end - - it 'instantiates an instance of MultiStore' do - subject.with do |redis_instance| - expect(redis_instance).to be_instance_of(::Gitlab::Redis::MultiStore) - - expect(redis_instance.primary_store.connection[:id]).to eq("redis://test-host:6379/99") - expect(redis_instance.primary_store.connection[:namespace]).to be_nil - expect(redis_instance.secondary_store.connection[:id]).to eq("unix:///path/to/redis.sock/0") - expect(redis_instance.secondary_store.connection[:namespace]).to eq("resque:gitlab") - - expect(redis_instance.instance_name).to eq('DuplicateJobs') - end - end - end - - # Make sure they current namespace is respected for the secondary store but omitted from the primary - context 'key namespaces' do - let(:key) { 'key' } - let(:value) { '123' } - - it 'writes keys to SharedState with no prefix, and to Queues with the "resque:gitlab:" prefix' do - subject.with do |redis_instance| - redis_instance.set(key, value) - end - - Gitlab::Redis::SharedState.with do |redis_instance| - expect(redis_instance.get(key)).to eq(value) - end - - Gitlab::Redis::Queues.with do |redis_instance| - expect(redis_instance.get("resque:gitlab:#{key}")).to eq(value) - end - end - end - - it_behaves_like 'multi store feature flags', :use_primary_and_secondary_stores_for_duplicate_jobs, - :use_primary_store_as_default_for_duplicate_jobs - end - - describe '#raw_config_hash' do - it 'has a legacy default URL' do - expect(subject).to receive(:fetch_config) { false } - - expect(subject.send(:raw_config_hash)).to eq(url: 'redis://localhost:6382') - end - end - - describe '#store_name' do - it 'returns the name of the SharedState store' do - expect(described_class.store_name).to eq('SharedState') - end - end -end diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb index 9532a30144f..0770e7b9f7d 100644 --- a/spec/lib/gitlab/regex_spec.rb +++ b/spec/lib/gitlab/regex_spec.rb @@ -608,6 +608,7 @@ RSpec.describe Gitlab::Regex, feature_category: :tooling do it { is_expected.to match('1.0') } it { is_expected.to match('1.0~alpha1') } it { is_expected.to match('2:4.9.5+dfsg-5+deb10u1') } + it { is_expected.to match('0.0.0-806aa143-f0bf-4f27-be65-8e4fcb745f37') } end context 'dpkg errors' do diff --git a/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb b/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb index b6748d49739..6a515a2b8a5 100644 --- a/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb +++ b/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb @@ -77,7 +77,11 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::DuplicateJob, :clean_gi end end - shared_examples 'with Redis cookies' do + context 'with Redis cookies' do + def with_redis(&block) + Sidekiq.redis(&block) + end + let(:cookie_key) { "#{idempotency_key}:cookie:v2" } let(:cookie) { get_redis_msgpack(cookie_key) } @@ -385,41 +389,6 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::DuplicateJob, :clean_gi end end - context 'with multi-store feature flags turned on' do - def with_redis(&block) - Gitlab::Redis::DuplicateJobs.with(&block) - end - - it 'use Gitlab::Redis::DuplicateJobs.with' do - expect(Gitlab::Redis::DuplicateJobs).to receive(:with).and_call_original - expect(Sidekiq).not_to receive(:redis) - - duplicate_job.check! - end - - it_behaves_like 'with Redis cookies' - end - - context 'when both multi-store feature flags are off' do - def with_redis(&block) - Sidekiq.redis(&block) - end - - before do - stub_feature_flags(use_primary_and_secondary_stores_for_duplicate_jobs: false) - stub_feature_flags(use_primary_store_as_default_for_duplicate_jobs: false) - end - - it 'use Sidekiq.redis' do - expect(Sidekiq).to receive(:redis).and_call_original - expect(Gitlab::Redis::DuplicateJobs).not_to receive(:with) - - duplicate_job.check! - end - - it_behaves_like 'with Redis cookies' - end - describe '#scheduled?' do it 'returns false for non-scheduled jobs' do expect(duplicate_job.scheduled?).to be(false) diff --git a/spec/migrations/20210811122206_update_external_project_bots_spec.rb b/spec/migrations/20210811122206_update_external_project_bots_spec.rb index aa0bce63865..b18239f4fd5 100644 --- a/spec/migrations/20210811122206_update_external_project_bots_spec.rb +++ b/spec/migrations/20210811122206_update_external_project_bots_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe UpdateExternalProjectBots, :migration, feature_category: :users do +RSpec.describe UpdateExternalProjectBots, :migration, feature_category: :user_profile do def create_user(**extra_options) defaults = { projects_limit: 0, email: "#{extra_options[:username]}@example.com" } diff --git a/spec/migrations/20210914095310_cleanup_orphan_project_access_tokens_spec.rb b/spec/migrations/20210914095310_cleanup_orphan_project_access_tokens_spec.rb index a9a814f9a48..a198ae9e473 100644 --- a/spec/migrations/20210914095310_cleanup_orphan_project_access_tokens_spec.rb +++ b/spec/migrations/20210914095310_cleanup_orphan_project_access_tokens_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe CleanupOrphanProjectAccessTokens, :migration, feature_category: :users do +RSpec.describe CleanupOrphanProjectAccessTokens, :migration, feature_category: :user_profile do def create_user(**extra_options) defaults = { state: 'active', projects_limit: 0, email: "#{extra_options[:username]}@example.com" } diff --git a/spec/migrations/20210922082019_drop_int4_column_for_events_spec.rb b/spec/migrations/20210922082019_drop_int4_column_for_events_spec.rb index f615c8bb50e..49cf1a01f2a 100644 --- a/spec/migrations/20210922082019_drop_int4_column_for_events_spec.rb +++ b/spec/migrations/20210922082019_drop_int4_column_for_events_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe DropInt4ColumnForEvents, feature_category: :users do +RSpec.describe DropInt4ColumnForEvents, feature_category: :user_profile do let(:events) { table(:events) } it 'correctly migrates up and down' do diff --git a/spec/migrations/20210922091402_drop_int4_column_for_push_event_payloads_spec.rb b/spec/migrations/20210922091402_drop_int4_column_for_push_event_payloads_spec.rb index 5c39e7530ff..3e241438339 100644 --- a/spec/migrations/20210922091402_drop_int4_column_for_push_event_payloads_spec.rb +++ b/spec/migrations/20210922091402_drop_int4_column_for_push_event_payloads_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe DropInt4ColumnForPushEventPayloads, feature_category: :users do +RSpec.describe DropInt4ColumnForPushEventPayloads, feature_category: :user_profile do let(:push_event_payloads) { table(:push_event_payloads) } it 'correctly migrates up and down' do diff --git a/spec/migrations/20221008032350_add_password_expiration_migration_spec.rb b/spec/migrations/20221008032350_add_password_expiration_migration_spec.rb index 1663966816c..ee6c2aeca9c 100644 --- a/spec/migrations/20221008032350_add_password_expiration_migration_spec.rb +++ b/spec/migrations/20221008032350_add_password_expiration_migration_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! -RSpec.describe AddPasswordExpirationMigration, feature_category: :users do +RSpec.describe AddPasswordExpirationMigration, feature_category: :user_profile do let(:application_setting) { table(:application_settings).create! } describe "#up" do diff --git a/spec/migrations/20221012033107_add_password_last_changed_at_to_user_details_spec.rb b/spec/migrations/20221012033107_add_password_last_changed_at_to_user_details_spec.rb index e2c508938fd..5c228381b57 100644 --- a/spec/migrations/20221012033107_add_password_last_changed_at_to_user_details_spec.rb +++ b/spec/migrations/20221012033107_add_password_last_changed_at_to_user_details_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! -RSpec.describe AddPasswordLastChangedAtToUserDetails, feature_category: :users do +RSpec.describe AddPasswordLastChangedAtToUserDetails, feature_category: :user_profile do let!(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } let!(:users) { table(:users) } let!(:user) { create_user! } diff --git a/spec/migrations/20221013154159_update_invalid_dormant_user_setting_spec.rb b/spec/migrations/20221013154159_update_invalid_dormant_user_setting_spec.rb index 0686d9ca786..ad644b63060 100644 --- a/spec/migrations/20221013154159_update_invalid_dormant_user_setting_spec.rb +++ b/spec/migrations/20221013154159_update_invalid_dormant_user_setting_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe UpdateInvalidDormantUserSetting, :migration, feature_category: :users do +RSpec.describe UpdateInvalidDormantUserSetting, :migration, feature_category: :user_profile do let(:settings) { table(:application_settings) } context 'with no rows in the application_settings table' do diff --git a/spec/migrations/20221025043930_change_default_value_on_password_last_changed_at_to_user_details_spec.rb b/spec/migrations/20221025043930_change_default_value_on_password_last_changed_at_to_user_details_spec.rb index d6acf31fdc6..0e5bb419e32 100644 --- a/spec/migrations/20221025043930_change_default_value_on_password_last_changed_at_to_user_details_spec.rb +++ b/spec/migrations/20221025043930_change_default_value_on_password_last_changed_at_to_user_details_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe ChangeDefaultValueOnPasswordLastChangedAtToUserDetails, :migration, feature_category: :users do +RSpec.describe ChangeDefaultValueOnPasswordLastChangedAtToUserDetails, :migration, feature_category: :user_profile do let(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } let(:users) { table(:users) } let(:user_details) { table(:user_details) } diff --git a/spec/migrations/20221028022627_add_index_on_password_last_changed_at_to_user_details_spec.rb b/spec/migrations/20221028022627_add_index_on_password_last_changed_at_to_user_details_spec.rb index 6b6fb553b1f..332b3a5abba 100644 --- a/spec/migrations/20221028022627_add_index_on_password_last_changed_at_to_user_details_spec.rb +++ b/spec/migrations/20221028022627_add_index_on_password_last_changed_at_to_user_details_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe AddIndexOnPasswordLastChangedAtToUserDetails, :migration, feature_category: :users do +RSpec.describe AddIndexOnPasswordLastChangedAtToUserDetails, :migration, feature_category: :user_profile do let(:index_name) { 'index_user_details_on_password_last_changed_at' } it 'correctly migrates up and down' do diff --git a/spec/migrations/cleanup_after_fixing_issue_when_admin_changed_primary_email_spec.rb b/spec/migrations/cleanup_after_fixing_issue_when_admin_changed_primary_email_spec.rb index e8dce46bdbc..7c9d2e3170a 100644 --- a/spec/migrations/cleanup_after_fixing_issue_when_admin_changed_primary_email_spec.rb +++ b/spec/migrations/cleanup_after_fixing_issue_when_admin_changed_primary_email_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe CleanupAfterFixingIssueWhenAdminChangedPrimaryEmail, :sidekiq, feature_category: :users do +RSpec.describe CleanupAfterFixingIssueWhenAdminChangedPrimaryEmail, :sidekiq, feature_category: :user_profile do let(:migration) { described_class.new } let(:users) { table(:users) } let(:emails) { table(:emails) } diff --git a/spec/migrations/cleanup_after_fixing_regression_with_new_users_emails_spec.rb b/spec/migrations/cleanup_after_fixing_regression_with_new_users_emails_spec.rb index 01ceef9f3a1..ce7be6aed73 100644 --- a/spec/migrations/cleanup_after_fixing_regression_with_new_users_emails_spec.rb +++ b/spec/migrations/cleanup_after_fixing_regression_with_new_users_emails_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe CleanupAfterFixingRegressionWithNewUsersEmails, :sidekiq, feature_category: :users do +RSpec.describe CleanupAfterFixingRegressionWithNewUsersEmails, :sidekiq, feature_category: :user_profile do let(:migration) { described_class.new } let(:users) { table(:users) } let(:emails) { table(:emails) } diff --git a/spec/migrations/confirm_security_bot_spec.rb b/spec/migrations/confirm_security_bot_spec.rb index 3761c113692..55053c29233 100644 --- a/spec/migrations/confirm_security_bot_spec.rb +++ b/spec/migrations/confirm_security_bot_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe ConfirmSecurityBot, :migration, feature_category: :users do +RSpec.describe ConfirmSecurityBot, :migration, feature_category: :user_profile do let(:users) { table(:users) } let(:user_type) { 8 } diff --git a/spec/migrations/fix_batched_migrations_old_format_job_arguments_spec.rb b/spec/migrations/fix_batched_migrations_old_format_job_arguments_spec.rb index 8def53e1858..7c03ed2c870 100644 --- a/spec/migrations/fix_batched_migrations_old_format_job_arguments_spec.rb +++ b/spec/migrations/fix_batched_migrations_old_format_job_arguments_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! # rubocop:disable Style/WordArray -RSpec.describe FixBatchedMigrationsOldFormatJobArguments, feature_category: :users do +RSpec.describe FixBatchedMigrationsOldFormatJobArguments, feature_category: :user_profile do let(:batched_background_migrations) { table(:batched_background_migrations) } context 'when migrations with legacy job arguments exists' do diff --git a/spec/migrations/queue_backfill_user_details_fields_spec.rb b/spec/migrations/queue_backfill_user_details_fields_spec.rb index e77a66907de..4613a85be40 100644 --- a/spec/migrations/queue_backfill_user_details_fields_spec.rb +++ b/spec/migrations/queue_backfill_user_details_fields_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe QueueBackfillUserDetailsFields, feature_category: :users do +RSpec.describe QueueBackfillUserDetailsFields, feature_category: :user_profile do let!(:batched_migration) { described_class::MIGRATION } it 'schedules a new batched migration' do diff --git a/spec/migrations/queue_populate_projects_star_count_spec.rb b/spec/migrations/queue_populate_projects_star_count_spec.rb index 84565d14d52..b30bb6a578b 100644 --- a/spec/migrations/queue_populate_projects_star_count_spec.rb +++ b/spec/migrations/queue_populate_projects_star_count_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe QueuePopulateProjectsStarCount, feature_category: :users do +RSpec.describe QueuePopulateProjectsStarCount, feature_category: :user_profile do let!(:batched_migration) { described_class::MIGRATION } it 'schedules a new batched migration' do diff --git a/spec/migrations/set_email_confirmation_setting_before_removing_send_user_confirmation_email_column_spec.rb b/spec/migrations/set_email_confirmation_setting_before_removing_send_user_confirmation_email_column_spec.rb index 4303713744e..8e00fbe4b89 100644 --- a/spec/migrations/set_email_confirmation_setting_before_removing_send_user_confirmation_email_column_spec.rb +++ b/spec/migrations/set_email_confirmation_setting_before_removing_send_user_confirmation_email_column_spec.rb @@ -3,7 +3,8 @@ require 'spec_helper' require_migration! -RSpec.describe SetEmailConfirmationSettingBeforeRemovingSendUserConfirmationEmailColumn, feature_category: :users do +RSpec.describe SetEmailConfirmationSettingBeforeRemovingSendUserConfirmationEmailColumn, + feature_category: :user_profile do let(:migration) { described_class.new } let(:application_settings_table) { table(:application_settings) } diff --git a/spec/migrations/set_email_confirmation_setting_from_send_user_confirmation_email_setting_spec.rb b/spec/migrations/set_email_confirmation_setting_from_send_user_confirmation_email_setting_spec.rb index e08aa8679a1..ef1ced530c9 100644 --- a/spec/migrations/set_email_confirmation_setting_from_send_user_confirmation_email_setting_spec.rb +++ b/spec/migrations/set_email_confirmation_setting_from_send_user_confirmation_email_setting_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require_migration! -RSpec.describe SetEmailConfirmationSettingFromSendUserConfirmationEmailSetting, feature_category: :users do +RSpec.describe SetEmailConfirmationSettingFromSendUserConfirmationEmailSetting, feature_category: :user_profile do let(:migration) { described_class.new } let(:application_settings_table) { table(:application_settings) } diff --git a/spec/models/achievements/achievement_spec.rb b/spec/models/achievements/achievement_spec.rb index 9a5f4eee229..d3e3e40fc0c 100644 --- a/spec/models/achievements/achievement_spec.rb +++ b/spec/models/achievements/achievement_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Achievements::Achievement, type: :model, feature_category: :users do +RSpec.describe Achievements::Achievement, type: :model, feature_category: :user_profile do describe 'associations' do it { is_expected.to belong_to(:namespace).required } diff --git a/spec/models/achievements/user_achievement_spec.rb b/spec/models/achievements/user_achievement_spec.rb index a91cba2b5e2..9d88bfdd477 100644 --- a/spec/models/achievements/user_achievement_spec.rb +++ b/spec/models/achievements/user_achievement_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Achievements::UserAchievement, type: :model, feature_category: :users do +RSpec.describe Achievements::UserAchievement, type: :model, feature_category: :user_profile do describe 'associations' do it { is_expected.to belong_to(:achievement).inverse_of(:user_achievements).required } it { is_expected.to belong_to(:user).inverse_of(:user_achievements).required } diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index f170eeb5841..931d12b7109 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Event, feature_category: :users do +RSpec.describe Event, feature_category: :user_profile do let_it_be_with_reload(:project) { create(:project) } describe "Associations" do diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb index b623d534f29..94c463dfe43 100644 --- a/spec/models/protected_branch_spec.rb +++ b/spec/models/protected_branch_spec.rb @@ -214,7 +214,6 @@ RSpec.describe ProtectedBranch do let_it_be(:project) { create(:project, :repository) } let_it_be(:protected_branch) { create(:protected_branch, project: project, name: "“jawn”") } - let(:use_new_cache_implementation) { true } let(:rely_on_new_cache) { true } shared_examples_for 'hash based cache implementation' do @@ -230,7 +229,6 @@ RSpec.describe ProtectedBranch do end before do - stub_feature_flags(hash_based_cache_for_protected_branches: use_new_cache_implementation) stub_feature_flags(rely_on_protected_branches_cache: rely_on_new_cache) allow(described_class).to receive(:matching).and_call_original @@ -296,48 +294,6 @@ RSpec.describe ProtectedBranch do expect(described_class.protected?(project, protected_branch.name)).to eq(true) end end - - context 'when feature flag hash_based_cache_for_protected_branches is off' do - let(:use_new_cache_implementation) { false } - - it 'does not call hash based cache implementation' do - expect(ProtectedBranches::CacheService).not_to receive(:new) - expect(Rails.cache).to receive(:fetch).and_call_original - - described_class.protected?(project, 'missing-branch') - end - - it 'correctly invalidates a cache' do - expect(described_class).to receive(:matching).with(protected_branch.name, protected_refs: anything).once.and_call_original - - create(:protected_branch, project: project, name: "bar") - # the cache is invalidated because the project has been "updated" - expect(described_class.protected?(project, protected_branch.name)).to eq(true) - end - - it 'sets expires_in of 1 hour for the Rails cache key' do - cache_key = described_class.protected_ref_cache_key(project, protected_branch.name) - - expect(Rails.cache).to receive(:fetch).with(cache_key, expires_in: 1.hour) - - described_class.protected?(project, protected_branch.name) - end - - context 'when project is updated' do - it 'invalidates Rails cache' do - expect(described_class).to receive(:matching).with(protected_branch.name, protected_refs: anything).once.and_call_original - - project.touch - - described_class.protected?(project, protected_branch.name) - end - end - - it 'correctly uses the cached version' do - expect(described_class).not_to receive(:matching) - expect(described_class.protected?(project, protected_branch.name)).to eq(true) - end - end end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e2e4e4248d8..5570eb36c81 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe User, feature_category: :users do +RSpec.describe User, feature_category: :user_profile do include ProjectForksHelper include TermsHelper include ExclusiveLeaseHelpers diff --git a/spec/requests/api/avatar_spec.rb b/spec/requests/api/avatar_spec.rb index 8affbe6ec2b..fcef5b6ca78 100644 --- a/spec/requests/api/avatar_spec.rb +++ b/spec/requests/api/avatar_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Avatar, feature_category: :users do +RSpec.describe API::Avatar, feature_category: :user_profile do let(:gravatar_service) { double('GravatarService') } describe 'GET /avatar' do diff --git a/spec/requests/api/events_spec.rb b/spec/requests/api/events_spec.rb index 5c061a37ff3..f884aaabb53 100644 --- a/spec/requests/api/events_spec.rb +++ b/spec/requests/api/events_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Events, feature_category: :users do +RSpec.describe API::Events, feature_category: :user_profile do let(:user) { create(:user) } let(:non_member) { create(:user) } let(:private_project) { create(:project, :private, creator_id: user.id, namespace: user.namespace) } diff --git a/spec/requests/api/graphql/ci/runner_spec.rb b/spec/requests/api/graphql/ci/runner_spec.rb index ca08e780758..1d40d8291b5 100644 --- a/spec/requests/api/graphql/ci/runner_spec.rb +++ b/spec/requests/api/graphql/ci/runner_spec.rb @@ -647,6 +647,11 @@ RSpec.describe 'Query.runner(id)', feature_category: :runner_fleet do icon text } + project { + id + name + webUrl + } shortSha commitPath finishedAt diff --git a/spec/requests/api/graphql/mutations/achievements/create_spec.rb b/spec/requests/api/graphql/mutations/achievements/create_spec.rb index 1713f050540..1e2f0dd777f 100644 --- a/spec/requests/api/graphql/mutations/achievements/create_spec.rb +++ b/spec/requests/api/graphql/mutations/achievements/create_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Mutations::Achievements::Create, feature_category: :users do +RSpec.describe Mutations::Achievements::Create, feature_category: :user_profile do include GraphqlHelpers include WorkhorseHelpers diff --git a/spec/requests/api/graphql/mutations/user_preferences/update_spec.rb b/spec/requests/api/graphql/mutations/user_preferences/update_spec.rb index 31d17401b9e..967ad75c906 100644 --- a/spec/requests/api/graphql/mutations/user_preferences/update_spec.rb +++ b/spec/requests/api/graphql/mutations/user_preferences/update_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Mutations::UserPreferences::Update, feature_category: :users do +RSpec.describe Mutations::UserPreferences::Update, feature_category: :user_profile do include GraphqlHelpers let_it_be(:current_user) { create(:user) } diff --git a/spec/requests/api/graphql/user_spec.rb b/spec/requests/api/graphql/user_spec.rb index 3e82d783a18..c19dfa6f3f3 100644 --- a/spec/requests/api/graphql/user_spec.rb +++ b/spec/requests/api/graphql/user_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User', feature_category: :users do +RSpec.describe 'User', feature_category: :user_profile do include GraphqlHelpers let_it_be(:current_user) { create(:user) } diff --git a/spec/requests/api/invitations_spec.rb b/spec/requests/api/invitations_spec.rb index 9d3ab269ca1..bb0f557cfee 100644 --- a/spec/requests/api/invitations_spec.rb +++ b/spec/requests/api/invitations_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Invitations, feature_category: :users do +RSpec.describe API::Invitations, feature_category: :user_profile do let_it_be(:maintainer) { create(:user, username: 'maintainer_user') } let_it_be(:maintainer2) { create(:user, username: 'user-with-maintainer-role') } let_it_be(:developer) { create(:user) } diff --git a/spec/requests/api/project_events_spec.rb b/spec/requests/api/project_events_spec.rb index 69d8eb76cf3..f904cd8fd6c 100644 --- a/spec/requests/api/project_events_spec.rb +++ b/spec/requests/api/project_events_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::ProjectEvents, feature_category: :users do +RSpec.describe API::ProjectEvents, feature_category: :user_profile do let(:user) { create(:user) } let(:non_member) { create(:user) } let(:private_project) { create(:project, :private, creator_id: user.id, namespace: user.namespace) } diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index d62f8a32453..d817c8fbb59 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -2227,6 +2227,89 @@ RSpec.describe API::Projects do end end + describe 'GET /project/:id/share_locations' do + let_it_be(:root_group) { create(:group, :public, name: 'root group') } + let_it_be(:project_group1) { create(:group, :public, parent: root_group, name: 'group1') } + let_it_be(:project_group2) { create(:group, :public, parent: root_group, name: 'group2') } + let_it_be(:project) { create(:project, :private, group: project_group1) } + + shared_examples_for 'successful groups response' do + it 'returns an array of groups' do + request + + aggregate_failures do + expect(response).to have_gitlab_http_status(:ok) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response.map { |g| g['name'] }).to match_array(expected_groups.map(&:name)) + end + end + end + + context 'when unauthenticated' do + it 'does not return the groups for the given project' do + get api("/projects/#{project.id}/share_locations") + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'when authenticated' do + context 'when user is not the owner of the project' do + it 'does not return the groups' do + get api("/projects/#{project.id}/share_locations", user) + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'when user is the owner of the project' do + let(:request) { get api("/projects/#{project.id}/share_locations", user), params: params } + let(:params) {} + + before do + project.add_owner(user) + project_group1.add_developer(user) + project_group2.add_developer(user) + end + + context 'with default search' do + it_behaves_like 'successful groups response' do + let(:expected_groups) { [project_group1, project_group2] } + end + end + + context 'when searching by group name' do + let(:params) { { search: 'group1' } } + + it_behaves_like 'successful groups response' do + let(:expected_groups) { [project_group1] } + end + end + end + end + + context 'when authenticated as admin' do + let(:request) { get api("/projects/#{project.id}/share_locations", admin), params: {} } + + context 'without share_with_group_lock' do + it_behaves_like 'successful groups response' do + let(:expected_groups) { [root_group, project_group1, project_group2] } + end + end + + context 'with share_with_group_lock' do + before do + project.namespace.update!(share_with_group_lock: true) + end + + it_behaves_like 'successful groups response' do + let(:expected_groups) { [] } + end + end + end + end + describe 'GET /projects/:id' do context 'when unauthenticated' do it 'does not return private projects' do @@ -2297,7 +2380,7 @@ RSpec.describe API::Projects do let(:project_attributes) { YAML.load_file(project_attributes_file) } let(:expected_keys) do - keys = project_attributes.map do |relation, relation_config| + keys = project_attributes.flat_map do |relation, relation_config| begin actual_keys = project.send(relation).attributes.keys rescue NoMethodError @@ -2307,7 +2390,7 @@ RSpec.describe API::Projects do remapped_attributes = relation_config['remapped_attributes'] || {} computed_attributes = relation_config['computed_attributes'] || [] actual_keys - unexposed_attributes - remapped_attributes.keys + remapped_attributes.values + computed_attributes - end.flatten + end unless Gitlab.ee? keys -= %w[ @@ -3662,8 +3745,8 @@ RSpec.describe API::Projects do aggregate_failures "testing response" do expect(response).to have_gitlab_http_status(:ok) - expect(json_response['avatar_url']).to eq('http://localhost/uploads/'\ - '-/system/project/avatar/'\ + expect(json_response['avatar_url']).to eq('http://localhost/uploads/' \ + '-/system/project/avatar/' \ "#{project3.id}/banana_sample.gif") end end @@ -3678,8 +3761,8 @@ RSpec.describe API::Projects do aggregate_failures "testing response" do expect(response).to have_gitlab_http_status(:ok) - expect(json_response['avatar_url']).to eq('http://localhost/uploads/'\ - '-/system/project/avatar/'\ + expect(json_response['avatar_url']).to eq('http://localhost/uploads/' \ + '-/system/project/avatar/' \ "#{project_with_avatar.id}/rails_sample.png") end end @@ -3695,8 +3778,8 @@ RSpec.describe API::Projects do aggregate_failures "testing response" do expect(response).to have_gitlab_http_status(:ok) expect(json_response['description']).to eq('changed description') - expect(json_response['avatar_url']).to eq('http://localhost/uploads/'\ - '-/system/project/avatar/'\ + expect(json_response['avatar_url']).to eq('http://localhost/uploads/' \ + '-/system/project/avatar/' \ "#{project_with_avatar.id}/banana_sample.gif") end end diff --git a/spec/requests/api/users_preferences_spec.rb b/spec/requests/api/users_preferences_spec.rb index 53f366371e5..ef9735fd8b0 100644 --- a/spec/requests/api/users_preferences_spec.rb +++ b/spec/requests/api/users_preferences_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Users, feature_category: :users do +RSpec.describe API::Users, feature_category: :user_profile do let_it_be(:user) { create(:user) } describe 'PUT /user/preferences/' do diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index c063187fdf4..34867b13db2 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Users, feature_category: :users do +RSpec.describe API::Users, feature_category: :user_profile do include WorkhorseHelpers let_it_be(:admin) { create(:admin) } diff --git a/spec/requests/projects/noteable_notes_spec.rb b/spec/requests/projects/noteable_notes_spec.rb index 5699bf17b80..084cf2d4a5c 100644 --- a/spec/requests/projects/noteable_notes_spec.rb +++ b/spec/requests/projects/noteable_notes_spec.rb @@ -36,5 +36,41 @@ RSpec.describe 'Project noteable notes', feature_category: :team_planning do expect(response).to have_gitlab_http_status(:ok) expect(response_etag).to eq(stored_etag) end + + it "instruments cache hits correctly" do + etag_store.touch(notes_path) + + expect(Gitlab::Metrics::RailsSlis.request_apdex).to( + receive(:increment).with( + labels: { + request_urgency: :low, + feature_category: "team_planning", + endpoint_id: "Projects::NotesController#index" + }, + success: be_in([true, false]) + ) + ) + allow(ActiveSupport::Notifications).to receive(:instrument).and_call_original + + expect(ActiveSupport::Notifications).to( + receive(:instrument).with( + 'process_action.action_controller', + a_hash_including( + { + request_urgency: :low, + target_duration_s: 5, + metadata: a_hash_including({ + 'meta.feature_category' => 'team_planning', + 'meta.caller_id' => "Projects::NotesController#index" + }) + } + ) + ) + ) + + get notes_path, headers: { "if-none-match": stored_etag } + + expect(response).to have_gitlab_http_status(:not_modified) + end end end diff --git a/spec/requests/user_activity_spec.rb b/spec/requests/user_activity_spec.rb index f9682d81640..16188ab6a41 100644 --- a/spec/requests/user_activity_spec.rb +++ b/spec/requests/user_activity_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Update of user activity', feature_category: :users do +RSpec.describe 'Update of user activity', feature_category: :user_profile do paths_to_visit = [ '/group', '/group/project', diff --git a/spec/requests/user_avatar_spec.rb b/spec/requests/user_avatar_spec.rb index 4e3c2744d56..0a9f3784833 100644 --- a/spec/requests/user_avatar_spec.rb +++ b/spec/requests/user_avatar_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Loading a user avatar', feature_category: :users do +RSpec.describe 'Loading a user avatar', feature_category: :user_profile do let(:user) { create(:user, :with_avatar) } context 'when logged in' do diff --git a/spec/services/achievements/create_service_spec.rb b/spec/services/achievements/create_service_spec.rb index f62a45deb50..ac28a88572b 100644 --- a/spec/services/achievements/create_service_spec.rb +++ b/spec/services/achievements/create_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Achievements::CreateService, feature_category: :users do +RSpec.describe Achievements::CreateService, feature_category: :user_profile do describe '#execute' do let_it_be(:user) { create(:user) } diff --git a/spec/services/chat_names/authorize_user_service_spec.rb b/spec/services/chat_names/authorize_user_service_spec.rb index 4c261ece504..c9b4439202a 100644 --- a/spec/services/chat_names/authorize_user_service_spec.rb +++ b/spec/services/chat_names/authorize_user_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe ChatNames::AuthorizeUserService, feature_category: :users do +RSpec.describe ChatNames::AuthorizeUserService, feature_category: :user_profile do describe '#execute' do let(:result) { subject.execute } diff --git a/spec/services/packages/debian/process_package_file_service_spec.rb b/spec/services/packages/debian/process_package_file_service_spec.rb index 571861f42cf..5eb4a7e79ca 100644 --- a/spec/services/packages/debian/process_package_file_service_spec.rb +++ b/spec/services/packages/debian/process_package_file_service_spec.rb @@ -1,20 +1,32 @@ # frozen_string_literal: true require 'spec_helper' -RSpec.describe Packages::Debian::ProcessPackageFileService do +RSpec.describe Packages::Debian::ProcessPackageFileService, feature_category: :package_registry do describe '#execute' do - let_it_be(:user) { create(:user) } let_it_be_with_reload(:distribution) { create(:debian_project_distribution, :with_file, codename: 'unstable') } - let!(:incoming) { create(:debian_incoming, project: distribution.project) } - + let!(:package) { create(:debian_package, :processing, project: distribution.project, published_in: nil) } let(:distribution_name) { distribution.codename } let(:debian_file_metadatum) { package_file.debian_file_metadatum } - subject { described_class.new(package_file, user, distribution_name, component_name) } + subject { described_class.new(package_file, distribution_name, component_name) } - RSpec.shared_context 'with Debian package file' do |file_name| - let(:package_file) { incoming.package_files.with_file_name(file_name).first } + shared_examples 'updates package and package file' do + it 'updates package and package file', :aggregate_failures do + expect(::Packages::Debian::GenerateDistributionWorker) + .to receive(:perform_async).with(:project, distribution.id) + expect { subject.execute } + .to not_change(Packages::Package, :count) + .and not_change(Packages::PackageFile, :count) + .and change(Packages::Debian::Publication, :count).by(1) + .and not_change(package.package_files, :count) + .and change { package.reload.name }.to('sample') + .and change { package.reload.version }.to('1.2.3~alpha2') + .and change { package.reload.status }.from('processing').to('default') + .and change { package.reload.debian_publication }.from(nil) + .and change(debian_file_metadatum, :file_type).from('unknown').to(expected_file_type) + .and change(debian_file_metadatum, :component).from(nil).to(component_name) + end end using RSpec::Parameterized::TableSyntax @@ -25,59 +37,62 @@ RSpec.describe Packages::Debian::ProcessPackageFileService do end with_them do - include_context 'with Debian package file', params[:file_name] do - it 'creates package and updates package file', :aggregate_failures do - expect(::Packages::Debian::GenerateDistributionWorker) - .to receive(:perform_async).with(:project, distribution.id) - expect { subject.execute } - .to change(Packages::Package, :count).from(1).to(2) - .and not_change(Packages::PackageFile, :count) - .and change(incoming.package_files, :count).from(7).to(6) - .and change(debian_file_metadatum, :file_type).from('unknown').to(expected_file_type) - .and change(debian_file_metadatum, :component).from(nil).to(component_name) - - created_package = Packages::Package.last - expect(created_package.name).to eq 'sample' - expect(created_package.version).to eq '1.2.3~alpha2' - expect(created_package.creator).to eq user - end + context 'with Debian package file' do + let(:package_file) { package.package_files.with_file_name(file_name).first } - context 'with existing package' do - let_it_be_with_reload(:existing_package) do - create(:debian_package, name: 'sample', version: '1.2.3~alpha2', project: distribution.project) - end + context 'when there is no matching published package' do + it_behaves_like 'updates package and package file' + end - before do - existing_package.update!(debian_distribution: distribution) + context 'when there is a matching published package' do + let!(:matching_package) do + create( + :debian_package, + project: distribution.project, + published_in: distribution, + name: 'sample', + version: '1.2.3~alpha2' + ) end - it 'does not create a package and assigns the package_file to the existing package' do + it 'reuses existing package and update package file', :aggregate_failures do expect(::Packages::Debian::GenerateDistributionWorker) .to receive(:perform_async).with(:project, distribution.id) expect { subject.execute } - .to not_change(Packages::Package, :count) - .and not_change(Packages::PackageFile, :count) - .and change(incoming.package_files, :count).from(7).to(6) - .and change(package_file, :package).from(incoming).to(existing_package) - .and change(debian_file_metadatum, :file_type).from('unknown').to(expected_file_type.to_s) + .to change(Packages::Package, :count).from(2).to(1) + .and change(Packages::PackageFile, :count).from(14).to(8) + .and not_change(Packages::Debian::Publication, :count) + .and change(package.package_files, :count).from(7).to(0) + .and change(package_file, :package).from(package).to(matching_package) + .and not_change(matching_package, :name) + .and not_change(matching_package, :version) + .and change(debian_file_metadatum, :file_type).from('unknown').to(expected_file_type) .and change(debian_file_metadatum, :component).from(nil).to(component_name) - end - context 'when marked as pending_destruction' do - it 'does not re-use the existing package' do - existing_package.pending_destruction! + expect { package.reload } + .to raise_error(ActiveRecord::RecordNotFound) + end + end - expect { subject.execute } - .to change(Packages::Package, :count).by(1) - .and not_change(Packages::PackageFile, :count) - end + context 'when there is a matching published package pending destruction' do + let!(:matching_package) do + create( + :debian_package, + :pending_destruction, + project: distribution.project, + published_in: distribution, + name: 'sample', + version: '1.2.3~alpha2' + ) end + + it_behaves_like 'updates package and package file' end end end context 'without a distribution' do - let(:package_file) { incoming.package_files.with_file_name('libsample0_1.2.3~alpha2_amd64.deb').first } + let(:package_file) { package.package_files.with_file_name('libsample0_1.2.3~alpha2_amd64.deb').first } let(:component_name) { 'main' } before do @@ -89,7 +104,7 @@ RSpec.describe Packages::Debian::ProcessPackageFileService do expect { subject.execute } .to not_change(Packages::Package, :count) .and not_change(Packages::PackageFile, :count) - .and not_change(incoming.package_files, :count) + .and not_change(package.package_files, :count) .and raise_error(ActiveRecord::RecordNotFound) end end @@ -103,7 +118,7 @@ RSpec.describe Packages::Debian::ProcessPackageFileService do expect { subject.execute } .to not_change(Packages::Package, :count) .and not_change(Packages::PackageFile, :count) - .and not_change(incoming.package_files, :count) + .and not_change(package.package_files, :count) .and raise_error(ArgumentError, 'package file without Debian metadata') end end @@ -118,13 +133,13 @@ RSpec.describe Packages::Debian::ProcessPackageFileService do expect { subject.execute } .to not_change(Packages::Package, :count) .and not_change(Packages::PackageFile, :count) - .and not_change(incoming.package_files, :count) + .and not_change(package.package_files, :count) .and raise_error(ArgumentError, 'already processed package file') end end context 'with invalid package file type' do - let(:package_file) { incoming.package_files.with_file_name('sample_1.2.3~alpha2.tar.xz').first } + let(:package_file) { package.package_files.with_file_name('sample_1.2.3~alpha2.tar.xz').first } let(:component_name) { 'main' } it 'raise ArgumentError', :aggregate_failures do @@ -132,30 +147,9 @@ RSpec.describe Packages::Debian::ProcessPackageFileService do expect { subject.execute } .to not_change(Packages::Package, :count) .and not_change(Packages::PackageFile, :count) - .and not_change(incoming.package_files, :count) + .and not_change(package.package_files, :count) .and raise_error(ArgumentError, 'invalid package file type: source') end end - - context 'when creating package fails' do - let(:package_file) { incoming.package_files.with_file_name('libsample0_1.2.3~alpha2_amd64.deb').first } - let(:component_name) { 'main' } - - before do - allow_next_instance_of(::Packages::Debian::FindOrCreatePackageService) do |find_or_create_package_service| - allow(find_or_create_package_service) - .to receive(:execute).and_raise(ActiveRecord::ConnectionTimeoutError, 'connect timeout') - end - end - - it 're-raise error', :aggregate_failures do - expect(::Packages::Debian::GenerateDistributionWorker).not_to receive(:perform_async) - expect { subject.execute } - .to not_change(Packages::Package, :count) - .and not_change(Packages::PackageFile, :count) - .and not_change(incoming.package_files, :count) - .and raise_error(ActiveRecord::ConnectionTimeoutError, 'connect timeout') - end - end end end diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml index ea918cb3437..6cba9332347 100644 --- a/spec/support/rspec_order_todo.yml +++ b/spec/support/rspec_order_todo.yml @@ -10308,7 +10308,6 @@ - './spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb' - './spec/views/projects/pipelines/show.html.haml_spec.rb' - './spec/views/projects/project_members/index.html.haml_spec.rb' -- './spec/views/projects/runners/_specific_runners.html.haml_spec.rb' - './spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb' - './spec/views/projects/settings/integrations/edit.html.haml_spec.rb' - './spec/views/projects/settings/operations/show.html.haml_spec.rb' diff --git a/spec/views/projects/runners/_specific_runners.html.haml_spec.rb b/spec/views/projects/runners/_project_runners.html.haml_spec.rb index ce16e0d5ac6..8a7e693bdeb 100644 --- a/spec/views/projects/runners/_specific_runners.html.haml_spec.rb +++ b/spec/views/projects/runners/_project_runners.html.haml_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' -RSpec.describe 'projects/runners/specific_runners.html.haml' do +RSpec.describe 'projects/runners/_project_runners.html.haml', feature_category: :runner do describe 'render' do - let_it_be(:user) { create(:user) } - let_it_be(:project) { create(:project) } + let_it_be(:user) { build(:user) } + let_it_be(:project) { build(:project) } before do @project = project @@ -22,7 +22,7 @@ RSpec.describe 'projects/runners/specific_runners.html.haml' do end it 'enables the Remove project button for a project' do - render 'projects/runners/specific_runners', project: project + render 'projects/runners/project_runners', project: project expect(rendered).to have_selector '#js-install-runner' expect(rendered).not_to have_content 'Please contact an admin to register runners.' @@ -35,7 +35,7 @@ RSpec.describe 'projects/runners/specific_runners.html.haml' do end it 'does not enable the Remove project button for a project' do - render 'projects/runners/specific_runners', project: project + render 'projects/runners/project_runners', project: project expect(rendered).to have_content 'Please contact an admin to register runners.' expect(rendered).not_to have_selector '#js-install-runner' diff --git a/spec/views/shared/runners/_runner_details.html.haml_spec.rb b/spec/views/shared/runners/_runner_details.html.haml_spec.rb index 978750c8435..6e95f6e8075 100644 --- a/spec/views/shared/runners/_runner_details.html.haml_spec.rb +++ b/spec/views/shared/runners/_runner_details.html.haml_spec.rb @@ -46,7 +46,7 @@ RSpec.describe 'shared/runners/_runner_details.html.haml' do context 'when runner is of type project' do let(:runner) { create(:ci_runner, :project) } - it { is_expected.to have_content("Runner ##{runner.id} specific") } + it { is_expected.to have_content("Runner ##{runner.id} project") } end end diff --git a/spec/workers/packages/debian/process_package_file_worker_spec.rb b/spec/workers/packages/debian/process_package_file_worker_spec.rb index 7da79751697..f45bc07af0e 100644 --- a/spec/workers/packages/debian/process_package_file_worker_spec.rb +++ b/spec/workers/packages/debian/process_package_file_worker_spec.rb @@ -3,18 +3,19 @@ require 'spec_helper' RSpec.describe Packages::Debian::ProcessPackageFileWorker, type: :worker, feature_category: :package_registry do - let_it_be(:user) { create(:user) } let_it_be_with_reload(:distribution) { create(:debian_project_distribution, :with_file, codename: 'unstable') } + let_it_be_with_reload(:package) do + create(:debian_package, :processing, project: distribution.project, published_in: nil) + end - let(:incoming) { create(:debian_incoming, project: distribution.project) } let(:distribution_name) { distribution.codename } + let(:debian_file_metadatum) { package_file.debian_file_metadatum } let(:worker) { described_class.new } describe '#perform' do let(:package_file_id) { package_file.id } - let(:user_id) { user.id } - subject { worker.perform(package_file_id, user_id, distribution_name, component_name) } + subject { worker.perform(package_file_id, distribution_name, component_name) } shared_examples 'returns early without error' do it 'returns early without error' do @@ -34,7 +35,7 @@ RSpec.describe Packages::Debian::ProcessPackageFileWorker, type: :worker, featur with_them do context 'with Debian package file' do - let(:package_file) { incoming.package_files.with_file_name(file_name).first } + let(:package_file) { package.package_files.with_file_name(file_name).first } context 'with mocked service' do it 'calls ProcessPackageFileService' do @@ -48,57 +49,44 @@ RSpec.describe Packages::Debian::ProcessPackageFileWorker, type: :worker, featur end end - context 'with non existing user' do - let(:user_id) { non_existing_record_id } - - it_behaves_like 'returns early without error' - end - - context 'with nil user id' do - let(:user_id) { nil } - - it_behaves_like 'returns early without error' - end - context 'when the service raises an error' do - let(:package_file) { incoming.package_files.with_file_name('sample_1.2.3~alpha2.tar.xz').first } + let(:package_file) { package.package_files.with_file_name('sample_1.2.3~alpha2.tar.xz').first } - it 'removes package file', :aggregate_failures do + it 'marks the package as errored', :aggregate_failures do expect(Gitlab::ErrorTracking).to receive(:log_exception).with( instance_of(ArgumentError), package_file_id: package_file_id, - user_id: user_id, distribution_name: distribution_name, component_name: component_name ) expect { subject } .to not_change(Packages::Package, :count) - .and change { Packages::PackageFile.count }.by(-1) - .and change { incoming.package_files.count }.from(7).to(6) - - expect { package_file.reload }.to raise_error(ActiveRecord::RecordNotFound) + .and not_change { Packages::PackageFile.count } + .and not_change { package.package_files.count } + .and change { package.reload.status }.from('processing').to('error') end end it_behaves_like 'an idempotent worker' do - let(:job_args) { [package_file.id, user.id, distribution_name, component_name] } + let(:job_args) { [package_file.id, distribution_name, component_name] } it 'sets the Debian file type as deb', :aggregate_failures do + expect(::Packages::Debian::GenerateDistributionWorker) + .to receive(:perform_async).with(:project, distribution.id) expect(Gitlab::ErrorTracking).not_to receive(:log_exception) # Using subject inside this block will process the job multiple times expect { subject } - .to change { Packages::Package.count }.from(1).to(2) + .to not_change(Packages::Package, :count) .and not_change(Packages::PackageFile, :count) - .and change { incoming.package_files.count }.from(7).to(6) - .and change { - package_file&.debian_file_metadatum&.reload&.file_type - }.from('unknown').to(expected_file_type) - - created_package = Packages::Package.last - expect(created_package.name).to eq 'sample' - expect(created_package.version).to eq '1.2.3~alpha2' - expect(created_package.creator).to eq user + .and change { Packages::Debian::Publication.count }.by(1) + .and not_change(package.package_files, :count) + .and change { package.reload.name }.to('sample') + .and change { package.version }.to('1.2.3~alpha2') + .and change { package.status }.from('processing').to('default') + .and change { package.debian_publication }.from(nil) + .and change { debian_file_metadatum.reload.file_type }.from('unknown').to(expected_file_type) + .and change { debian_file_metadatum.component }.from(nil).to(component_name) end end end @@ -113,7 +101,7 @@ RSpec.describe Packages::Debian::ProcessPackageFileWorker, type: :worker, featur end context 'with a deb' do - let(:package_file) { incoming.package_files.with_file_name('libsample0_1.2.3~alpha2_amd64.deb').first } + let(:package_file) { package.package_files.with_file_name('libsample0_1.2.3~alpha2_amd64.deb').first } let(:component_name) { 'main' } context 'with non existing package file' do |