diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-18 03:07:23 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-18 03:07:23 +0000 |
commit | 962afb3da11a72c7fca322378886b2c0be9f3385 (patch) | |
tree | 541e08c4d329ab62cfbadde45b0f15d2171e004e | |
parent | 8a560d56661f56804ddf6596f928e7d25db37443 (diff) | |
download | gitlab-ce-962afb3da11a72c7fca322378886b2c0be9f3385.tar.gz |
29 files changed, 244 insertions, 41 deletions
diff --git a/.gitlab/ci/package-and-test-nightly/main.gitlab-ci.yml b/.gitlab/ci/package-and-test-nightly/main.gitlab-ci.yml index 239044457e5..85de1a28b66 100644 --- a/.gitlab/ci/package-and-test-nightly/main.gitlab-ci.yml +++ b/.gitlab/ci/package-and-test-nightly/main.gitlab-ci.yml @@ -5,7 +5,7 @@ include: workflow: rules: - - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULE_TYPE == "nightly"' + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $SCHEDULE_TYPE == "nightly"' .ce: variables: diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index e6ad520ccca..a5a1ff73c2b 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -1437,6 +1437,8 @@ .qa:rules:package-and-test-ee: rules: + - <<: *if-default-branch-schedule-nightly # already executed in the 2-hourly schedule + when: never - !reference [".qa:rules:package-and-test-common", rules] - !reference [".qa:rules:package-and-test-schedule", rules] @@ -1456,6 +1458,12 @@ changes: *code-qa-patterns when: manual allow_failure: true + - <<: *if-default-branch-schedule-nightly + allow_failure: true + variables: + SKIP_REPORT_IN_ISSUES: "false" + QA_SAVE_TEST_METRICS: "true" + QA_EXPORT_TEST_METRICS: "false" .qa:rules:e2e:test-on-gdk: rules: @@ -1487,6 +1495,7 @@ .qa:rules:package-and-test-nightly: rules: - <<: *if-default-branch-schedule-nightly + allow_failure: true variables: KNAPSACK_GENERATE_REPORT: "true" SKIP_REPORT_IN_ISSUES: "false" diff --git a/app/controllers/abuse_reports_controller.rb b/app/controllers/abuse_reports_controller.rb index edeac57bc42..55aef945702 100644 --- a/app/controllers/abuse_reports_controller.rb +++ b/app/controllers/abuse_reports_controller.rb @@ -64,8 +64,8 @@ class AbuseReportsController < ApplicationController if @user.nil? redirect_to root_path, alert: _("Cannot create the abuse report. The user has been deleted.") - elsif @user.blocked? - redirect_to @user, alert: _("Cannot create the abuse report. This user has been blocked.") + elsif @user.banned? + redirect_to @user, alert: _("Cannot create the abuse report. This user has been banned.") end end # rubocop: enable CodeReuse/ActiveRecord diff --git a/app/controllers/profiles/preferences_controller.rb b/app/controllers/profiles/preferences_controller.rb index a5a2cbf3733..f19113276c2 100644 --- a/app/controllers/profiles/preferences_controller.rb +++ b/app/controllers/profiles/preferences_controller.rb @@ -54,6 +54,7 @@ class Profiles::PreferencesController < Profiles::ApplicationController :sourcegraph_enabled, :gitpod_enabled, :render_whitespace_in_code, + :project_shortcut_buttons, :markdown_surround_selection, :markdown_automatic_lists, :use_new_navigation diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 60230d58e30..c6edb16e5a1 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -192,6 +192,18 @@ module UsersHelper } end + def moderation_status(user) + return unless user.present? + + if user.banned? + _('Banned') + elsif user.blocked? + _('Blocked') + else + _('Active') + end + end + private def admin_users_paths diff --git a/app/models/user.rb b/app/models/user.rb index 0c8ff873ba6..8075affdf03 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -361,6 +361,7 @@ class User < ApplicationRecord :sourcegraph_enabled, :sourcegraph_enabled=, :gitpod_enabled, :gitpod_enabled=, :setup_for_company, :setup_for_company=, + :project_shortcut_buttons, :project_shortcut_buttons=, :render_whitespace_in_code, :render_whitespace_in_code=, :markdown_surround_selection, :markdown_surround_selection=, :markdown_automatic_lists, :markdown_automatic_lists=, diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index 90449411f8a..e527542e357 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -35,6 +35,7 @@ class UserPreference < ApplicationRecord attribute :tab_width, default: -> { Gitlab::TabWidth::DEFAULT } attribute :time_display_relative, default: true attribute :render_whitespace_in_code, default: false + attribute :project_shortcut_buttons, default: true enum visibility_pipeline_id_type: { id: 0, iid: 1 } diff --git a/app/views/admin/spam_logs/_spam_log.html.haml b/app/views/admin/spam_logs/_spam_log.html.haml index 183667679b9..6aed8508a6a 100644 --- a/app/views/admin/spam_logs/_spam_log.html.haml +++ b/app/views/admin/spam_logs/_spam_log.html.haml @@ -22,6 +22,8 @@ %td = truncate(spam_log.description, length: 100) %td + = moderation_status(user) + %td - if user = render Pajamas::ButtonComponent.new(size: :small, variant: :danger, diff --git a/app/views/admin/spam_logs/index.html.haml b/app/views/admin/spam_logs/index.html.haml index 001662c4015..9a0756510ec 100644 --- a/app/views/admin/spam_logs/index.html.haml +++ b/app/views/admin/spam_logs/index.html.haml @@ -14,6 +14,7 @@ %th= _('Type') %th= _('Title') %th= _('Description') + %th= _('User Status') %th= _('Primary Action') %th = render @spam_logs diff --git a/app/views/profiles/preferences/show.html.haml b/app/views/profiles/preferences/show.html.haml index 7f8858411ca..19dc7a1d9b9 100644 --- a/app/views/profiles/preferences/show.html.haml +++ b/app/views/profiles/preferences/show.html.haml @@ -90,6 +90,8 @@ .form-text.text-muted = s_('Preferences|Choose what content you want to see on a project’s overview page.') .form-group + = f.gitlab_ui_checkbox_component :project_shortcut_buttons, s_('Preferences|Show shortcut buttons above files on project overview') + .form-group = f.gitlab_ui_checkbox_component :render_whitespace_in_code, s_('Preferences|Render whitespace characters in the Web IDE') .form-group = f.gitlab_ui_checkbox_component :show_whitespace_in_diffs, s_('Preferences|Show whitespace changes in diffs') diff --git a/app/views/projects/_files.html.haml b/app/views/projects/_files.html.haml index 5c7f83fc579..60535d704c4 100644 --- a/app/views/projects/_files.html.haml +++ b/app/views/projects/_files.html.haml @@ -2,6 +2,7 @@ - is_project_overview = local_assigns.fetch(:is_project_overview, false) - ref = local_assigns.fetch(:ref) { current_ref } - project = local_assigns.fetch(:project) { @project } +- has_project_shortcut_buttons = !current_user || current_user.project_shortcut_buttons - add_page_startup_api_call logs_file_project_ref_path(@project, ref, @path, format: "json", offset: 0) - if readme_path = @project.repository.readme_path - add_page_startup_api_call project_blob_path(@project, tree_join(@ref, readme_path), viewer: "rich", format: "json") @@ -18,7 +19,7 @@ - if project.forked? #js-fork-info{ data: vue_fork_divergence_data(project, ref) } - - if is_project_overview + - if is_project_overview && has_project_shortcut_buttons .project-buttons.gl-mb-5.js-show-on-project-root{ data: { qa_selector: 'project_buttons' } } = render 'stat_anchor_list', anchors: @project.statistics_buttons(show_auto_devops_callout: show_auto_devops_callout), project_buttons: true diff --git a/db/migrate/20230508095017_add_project_shortcut_buttons_to_user_preferences.rb b/db/migrate/20230508095017_add_project_shortcut_buttons_to_user_preferences.rb new file mode 100644 index 00000000000..e68148e17a5 --- /dev/null +++ b/db/migrate/20230508095017_add_project_shortcut_buttons_to_user_preferences.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddProjectShortcutButtonsToUserPreferences < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :user_preferences, :project_shortcut_buttons, :boolean, default: true, null: false + end +end diff --git a/db/post_migrate/20221207135755_finalize_add_namespaces_emails_enabled_column_data.rb b/db/post_migrate/20221207135755_finalize_add_namespaces_emails_enabled_column_data.rb new file mode 100644 index 00000000000..c4fc2aad60b --- /dev/null +++ b/db/post_migrate/20221207135755_finalize_add_namespaces_emails_enabled_column_data.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class FinalizeAddNamespacesEmailsEnabledColumnData < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + MIGRATION = 'AddNamespacesEmailsEnabledColumnData' + + def up + ensure_batched_background_migration_is_finished( + job_class_name: MIGRATION, + table_name: :namespaces, + column_name: :id, + job_arguments: [] + ) + end + + def down + # noop + end +end diff --git a/db/post_migrate/20221207135831_finalize_add_projects_emails_enabled_column_data.rb b/db/post_migrate/20221207135831_finalize_add_projects_emails_enabled_column_data.rb new file mode 100644 index 00000000000..6118be6d4c4 --- /dev/null +++ b/db/post_migrate/20221207135831_finalize_add_projects_emails_enabled_column_data.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class FinalizeAddProjectsEmailsEnabledColumnData < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + MIGRATION = 'AddProjectsEmailsEnabledColumnData' + + def up + ensure_batched_background_migration_is_finished( + job_class_name: MIGRATION, + table_name: :projects, + column_name: :id, + job_arguments: [] + ) + end + + def down + # noop + end +end diff --git a/db/schema_migrations/20221207135755 b/db/schema_migrations/20221207135755 new file mode 100644 index 00000000000..e8a97fc717e --- /dev/null +++ b/db/schema_migrations/20221207135755 @@ -0,0 +1 @@ +b08b766dad288ad5d4b6cfa0d92288a38f553f20dbea997d5379ef2dc79f1f0c
\ No newline at end of file diff --git a/db/schema_migrations/20221207135831 b/db/schema_migrations/20221207135831 new file mode 100644 index 00000000000..406e1e88841 --- /dev/null +++ b/db/schema_migrations/20221207135831 @@ -0,0 +1 @@ +ad6101b9d46b7a7ae1c302c7880979b5a29ced6193dfe95e32495766f01b34d9
\ No newline at end of file diff --git a/db/schema_migrations/20230508095017 b/db/schema_migrations/20230508095017 new file mode 100644 index 00000000000..00fefae99f6 --- /dev/null +++ b/db/schema_migrations/20230508095017 @@ -0,0 +1 @@ +02a4bd854b5f2269c917fa15823f423544a165a37a6341f76c6555e4b11659f3
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 5631d206fbb..b9c6a1eefd9 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -23561,6 +23561,7 @@ CREATE TABLE user_preferences ( pass_user_identities_to_ci_jwt boolean DEFAULT false NOT NULL, enabled_following boolean DEFAULT true NOT NULL, visibility_pipeline_id_type smallint DEFAULT 0 NOT NULL, + project_shortcut_buttons boolean DEFAULT true NOT NULL, CONSTRAINT check_89bf269f41 CHECK ((char_length(diffs_deletion_color) <= 7)), CONSTRAINT check_d07ccd35f7 CHECK ((char_length(diffs_addition_color) <= 7)) ); diff --git a/doc/development/fe_guide/haml.md b/doc/development/fe_guide/haml.md index 9dc5b265783..9281f01d750 100644 --- a/doc/development/fe_guide/haml.md +++ b/doc/development/fe_guide/haml.md @@ -67,10 +67,10 @@ For example: .form-group.gl-mb-3 = f.gitlab_ui_checkbox_component :lfs_enabled, checkbox_options: { checked: @group.lfs_enabled? } do |c| - = c.label do + - c.with_label do = _('Allow projects within this group to use Git LFS') = link_to sprite_icon('question-o'), help_page_path('topics/git/lfs/index') - = c.help_text do + - c.with_help_text do = _('This setting can be overridden in each project.') ``` diff --git a/doc/development/fe_guide/view_component.md b/doc/development/fe_guide/view_component.md index 0245110ec75..cfd78597501 100644 --- a/doc/development/fe_guide/view_component.md +++ b/doc/development/fe_guide/view_component.md @@ -66,7 +66,7 @@ In its simplest form the banner component looks like this: ```haml = render Pajamas::BannerComponent.new(button_text: 'Learn more', button_link: example_path, svg_path: 'illustrations/example.svg') do |c| - - c.title { 'Hello world!' } + - c.with_title { 'Hello world!' } %p Content of your banner goes here... ``` @@ -75,11 +75,11 @@ instead of `svg_path` and the `primary_action` slot instead of `button_text` and ```haml = render Pajamas::BannerComponent.new do |c| - - c.illustration do + - c.with_illustration do = custom_icon('my_inline_svg') - - c.title do + - c.with_title do Hello world! - - c.primary_action do + - c.with_primary_action do = render 'my_button_in_a_partial' ``` @@ -133,12 +133,12 @@ The card has one mandatory `body` slot and optional `header` and `footer` slots: ```haml = render Pajamas::CardComponent.new do |c| - - c.header do + - c.with_header do I'm the header. - - c.body do + - c.with_body do %p Multiple line %p body content. - - c.footer do + - c.with_footer do Footer goes here. ``` @@ -164,9 +164,9 @@ For example: ```haml = render Pajamas::CheckboxTagComponent.new(name: 'project[initialize_with_sast]', checkbox_options: { data: { qa_selector: 'initialize_with_sast_checkbox', track_label: track_label, track_action: 'activate_form_input', track_property: 'init_with_sast' } }) do |c| - = c.label do + - c.with_label do = s_('ProjectsNew|Enable Static Application Security Testing (SAST)') - = c.help_text do + - c.with_help_text do = s_('ProjectsNew|Analyze your source code for known security vulnerabilities.') = link_to _('Learn more.'), help_page_path('user/application_security/sast/index'), target: '_blank', rel: 'noopener noreferrer', data: { track_action: 'followed' } ``` @@ -219,11 +219,11 @@ Many of the settings pages use a layout where the title and description are on t ```haml = render ::Layouts::HorizontalSectionComponent.new(options: { class: 'gl-mb-6' }) do |c| - = c.title { _('Naming, visibility') } - = c.description do + - c.with_title { _('Naming, visibility') } + - c.with_description do = _('Update your group name, description, avatar, and visibility.') = link_to _('Learn more about groups.'), help_page_path('user/group/index') - = c.body do + - c.with_body do .form-group.gl-form-group = f.label :name, _('New group name') = f.text_field :name diff --git a/doc/user/profile/preferences.md b/doc/user/profile/preferences.md index e72113dc321..ab7cc96d4c1 100644 --- a/doc/user/profile/preferences.md +++ b/doc/user/profile/preferences.md @@ -129,6 +129,8 @@ You can choose between 2 options: The **Project overview content** setting allows you to choose what content you want to see on a project's home page. +If **Files and Readme** is selected, you can show or hide the shortcut buttons above the file list on the project overview with the **Show shortcut buttons above files on project overview** setting. + ### Tab width You can set the displayed width of tab characters across various parts of diff --git a/locale/gitlab.pot b/locale/gitlab.pot index ccf1f669e2f..3e9e3045851 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -8760,7 +8760,7 @@ msgstr "" msgid "Cannot create the abuse report. The user has been deleted." msgstr "" -msgid "Cannot create the abuse report. This user has been blocked." +msgid "Cannot create the abuse report. This user has been banned." msgstr "" msgid "Cannot delete %{profile_name} referenced in security policy" @@ -33955,6 +33955,9 @@ msgstr "" msgid "Preferences|Show one file at a time on merge request's Changes tab" msgstr "" +msgid "Preferences|Show shortcut buttons above files on project overview" +msgstr "" + msgid "Preferences|Show whitespace changes in diffs" msgstr "" @@ -48688,6 +48691,9 @@ msgstr "" msgid "User Settings" msgstr "" +msgid "User Status" +msgstr "" + msgid "User and IP rate limits" msgstr "" diff --git a/spec/controllers/profiles/preferences_controller_spec.rb b/spec/controllers/profiles/preferences_controller_spec.rb index e2ade5e3de9..f5c97f63293 100644 --- a/spec/controllers/profiles/preferences_controller_spec.rb +++ b/spec/controllers/profiles/preferences_controller_spec.rb @@ -53,6 +53,7 @@ RSpec.describe Profiles::PreferencesController do first_day_of_week: '1', preferred_language: 'jp', tab_width: '5', + project_shortcut_buttons: 'true', render_whitespace_in_code: 'true' }.with_indifferent_access diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index f26c37a5ff2..0a259b80219 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -561,4 +561,36 @@ RSpec.describe UsersHelper do end end end + + describe '#moderation_status', feature_category: :instance_resiliency do + let(:user) { create(:user) } + + subject { moderation_status(user) } + + context 'when user is nil' do + let(:user) { nil } + + it { is_expected.to be_nil } + end + + context 'when a user is banned' do + before do + user.ban! + end + + it { is_expected.to eq('Banned') } + end + + context 'when a user is blocked' do + before do + user.block! + end + + it { is_expected.to eq('Blocked') } + end + + context 'when a user is active' do + it { is_expected.to eq('Active') } + end + end end diff --git a/spec/models/user_preference_spec.rb b/spec/models/user_preference_spec.rb index 1d7ecb724bf..17899012aaa 100644 --- a/spec/models/user_preference_spec.rb +++ b/spec/models/user_preference_spec.rb @@ -225,6 +225,20 @@ RSpec.describe UserPreference, feature_category: :user_profile do end end + describe '#project_shortcut_buttons' do + it 'is set to true by default' do + pref = described_class.new + + expect(pref.project_shortcut_buttons).to eq(true) + end + + it 'returns assigned value' do + pref = described_class.new(project_shortcut_buttons: false) + + expect(pref.project_shortcut_buttons).to eq(false) + end + end + describe '#render_whitespace_in_code' do it 'is set to false by default' do pref = described_class.new diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c73dac7251e..b2f695c8b5a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -60,6 +60,9 @@ RSpec.describe User, feature_category: :user_profile do it { is_expected.to delegate_method(:setup_for_company).to(:user_preference) } it { is_expected.to delegate_method(:setup_for_company=).to(:user_preference).with_arguments(:args) } + it { is_expected.to delegate_method(:project_shortcut_buttons).to(:user_preference) } + it { is_expected.to delegate_method(:project_shortcut_buttons=).to(:user_preference).with_arguments(:args) } + it { is_expected.to delegate_method(:render_whitespace_in_code).to(:user_preference) } it { is_expected.to delegate_method(:render_whitespace_in_code=).to(:user_preference).with_arguments(:args) } diff --git a/spec/requests/abuse_reports_controller_spec.rb b/spec/requests/abuse_reports_controller_spec.rb index 4b81394aea3..69b0fb41330 100644 --- a/spec/requests/abuse_reports_controller_spec.rb +++ b/spec/requests/abuse_reports_controller_spec.rb @@ -44,14 +44,14 @@ RSpec.describe AbuseReportsController, feature_category: :insider_threat do end end - context 'when the user has already been blocked' do + context 'when the user has already been banned' do it 'redirects the reporter to the user\'s profile' do - user.block + user.ban get new_abuse_report_path(user_id: user.id) expect(response).to redirect_to user - expect(flash[:alert]).to eq(_('Cannot create the abuse report. This user has been blocked.')) + expect(flash[:alert]).to eq(_('Cannot create the abuse report. This user has been banned.')) end end end @@ -127,16 +127,16 @@ RSpec.describe AbuseReportsController, feature_category: :insider_threat do end end - context 'when the user has already been blocked' do + context 'when the user has already been banned' do let(:request_params) { { user_id: user.id, abuse_report: { category: abuse_category } } } it 'redirects the reporter to the user\'s profile' do - user.block + user.ban subject expect(response).to redirect_to user - expect(flash[:alert]).to eq(_('Cannot create the abuse report. This user has been blocked.')) + expect(flash[:alert]).to eq(_('Cannot create the abuse report. This user has been banned.')) end end end diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index 012eb5f6fca..e9853642e76 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -496,13 +496,11 @@ RSpec.describe MergeRequests::UpdateService, :mailer, feature_category: :code_re before do merge_request.merge_error = 'Error' - perform_enqueued_jobs do - service.execute(merge_request) - @merge_request = MergeRequest.find(merge_request.id) - end + service.execute(merge_request) + @merge_request = MergeRequest.find(merge_request.id) end - it 'merges the MR', :sidekiq_might_not_need_inline do + it 'merges the MR', :sidekiq_inline do expect(@merge_request).to be_valid expect(@merge_request.state).to eq('merged') expect(@merge_request.merge_error).to be_nil @@ -517,13 +515,11 @@ RSpec.describe MergeRequests::UpdateService, :mailer, feature_category: :code_re sha: merge_request.diff_head_sha, status: :success) - perform_enqueued_jobs do - @merge_request = service.execute(merge_request) - @merge_request = MergeRequest.find(merge_request.id) - end + @merge_request = service.execute(merge_request) + @merge_request = MergeRequest.find(merge_request.id) end - it 'merges the MR', :sidekiq_might_not_need_inline do + it 'merges the MR', :sidekiq_inline do expect(@merge_request).to be_valid expect(@merge_request.state).to eq('merged') end @@ -674,7 +670,7 @@ RSpec.describe MergeRequests::UpdateService, :mailer, feature_category: :code_re expect(Todo.where(attributes).count).to eq 1 end - it 'sends email reviewer change notifications to old and new reviewers', :sidekiq_might_not_need_inline do + it 'sends email reviewer change notifications to old and new reviewers', :sidekiq_inline do merge_request.reviewers = [user2] perform_enqueued_jobs do @@ -719,7 +715,7 @@ RSpec.describe MergeRequests::UpdateService, :mailer, feature_category: :code_re end end - it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do + it 'sends notifications for subscribers of changed milestone', :sidekiq_inline do merge_request.milestone = create(:milestone, project: project) merge_request.save! @@ -751,7 +747,7 @@ RSpec.describe MergeRequests::UpdateService, :mailer, feature_category: :code_re update_merge_request(milestone_id: create(:milestone, project: project).id) end - it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do + it 'sends notifications for subscribers of changed milestone', :sidekiq_inline do perform_enqueued_jobs do update_merge_request(milestone_id: create(:milestone, project: project).id) end @@ -867,7 +863,7 @@ RSpec.describe MergeRequests::UpdateService, :mailer, feature_category: :code_re merge_request.update_attribute(:title, draft_title) end - it 'sends notifications for subscribers', :sidekiq_might_not_need_inline do + it 'sends notifications for subscribers', :sidekiq_inline do opts = { title: 'New title' } perform_enqueued_jobs do @@ -899,7 +895,7 @@ RSpec.describe MergeRequests::UpdateService, :mailer, feature_category: :code_re merge_request.update_attribute(:title, title) end - it 'does not send notifications', :sidekiq_might_not_need_inline do + it 'does not send notifications', :sidekiq_inline do opts = { title: 'Draft: New title' } perform_enqueued_jobs do @@ -936,7 +932,7 @@ RSpec.describe MergeRequests::UpdateService, :mailer, feature_category: :code_re project.add_developer(subscriber) end - it 'sends notifications for subscribers of newly added labels', :sidekiq_might_not_need_inline do + it 'sends notifications for subscribers of newly added labels', :sidekiq_inline do opts = { label_ids: [label.id] } perform_enqueued_jobs do diff --git a/spec/views/projects/_files.html.haml_spec.rb b/spec/views/projects/_files.html.haml_spec.rb new file mode 100644 index 00000000000..618a0948739 --- /dev/null +++ b/spec/views/projects/_files.html.haml_spec.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'projects/_files', feature_category: :projects do + let_it_be(:template) { 'projects/files' } + let_it_be(:namespace) { build_stubbed(:namespace) } + let_it_be(:user) { build_stubbed(:user, namespace: namespace) } + let_it_be(:project) { build_stubbed(:project, namespace: namespace) } + + before do + assign(:project, project) + assign(:path, '/job_path') + assign(:ref, 'main') + # used by project_new_blob_path + assign(:id, '1') + + allow(project).to receive(:statistics_buttons).and_return([]) + end + + context 'when the user disabled project shortcut buttons' do + before do + allow(view).to receive(:current_user).and_return(user) + allow(user).to receive(:project_shortcut_buttons).and_return(false) + end + + it 'does not render buttons' do + render(template, is_project_overview: true) + + expect(rendered).not_to have_selector('.js-show-on-project-root') + end + end + + context 'when the user has project shortcut buttons enabled' do + before do + allow(view).to receive(:current_user).and_return(user) + allow(user).to receive(:project_shortcut_buttons).and_return(true) + end + + it 'renders buttons' do + render(template, is_project_overview: true) + + expect(rendered).to have_selector('.js-show-on-project-root') + end + end + + context 'when rendered in the project overview page and there is no current user' do + it 'renders buttons' do + render(template, is_project_overview: true) + + expect(rendered).to have_selector('.js-show-on-project-root') + end + end + + context 'when rendered in a page other than project overview' do + it 'does not render buttons' do + render(template, is_project_overview: false) + + expect(rendered).not_to have_selector('.js-show-on-project-root') + end + end +end |