From 52f765baf4931efd40d10b1eb5f2818923ddf26f Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 25 Aug 2021 21:10:28 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../javascripts/lib/utils/text_markdown.js | 2 +- .../projects/pipelines/charts/index.js | 2 +- .../vue_shared/components/markdown/field.vue | 6 +--- app/graphql/resolvers/todo_resolver.rb | 7 +++++ .../types/alert_management/alert_type.rb | 4 +-- app/graphql/types/user_interface.rb | 4 +-- .../admin/application_settings/_eks.html.haml | 2 +- ...ernal_authorization_service_form.html.haml | 2 +- .../application_settings/_floc.html.haml | 2 +- .../application_settings/_gitpod.html.haml | 2 +- .../_import_export_limits.html.haml | 2 +- .../_issue_limits.html.haml | 2 +- .../application_settings/_outbound.html.haml | 2 +- .../_package_registry_limits.html.haml | 2 +- .../_protected_paths.html.haml | 2 +- app/views/projects/hooks/edit.html.haml | 2 +- .../projects/tags/releases/edit.html.haml | 2 +- app/views/shared/issuable/_form.html.haml | 2 +- app/views/shared/labels/_form.html.haml | 2 +- ...p_index_approval_project_rules_scanners.rb | 17 ++++++++++ db/schema_migrations/20210819152723 | 1 + db/structure.sql | 2 -- doc/.vale/gitlab/spelling-exceptions.txt | 1 + doc/api/graphql/reference/index.md | 4 +-- doc/development/graphql_guide/graphql_pro.md | 4 +-- doc/development/graphql_guide/index.md | 4 +-- doc/development/graphql_guide/pagination.md | 4 +-- lib/gitlab/changelog/config.rb | 2 +- .../field_extension.rb | 26 ---------------- spec/frontend/lib/utils/text_markdown_spec.js | 2 +- .../components/markdown/field_spec.js | 2 +- spec/lib/gitlab/changelog/config_spec.rb | 31 ++++++++++++++----- .../repositories/changelog_service_spec.rb | 2 +- tooling/graphql/docs/helper.rb | 4 +-- 34 files changed, 81 insertions(+), 76 deletions(-) create mode 100644 db/migrate/20210819152723_remove_tmp_index_approval_project_rules_scanners.rb create mode 100644 db/schema_migrations/20210819152723 delete mode 100644 lib/gitlab/graphql/todos_project_permission_preloader/field_extension.rb diff --git a/app/assets/javascripts/lib/utils/text_markdown.js b/app/assets/javascripts/lib/utils/text_markdown.js index 9038812c9cf..0804d792631 100644 --- a/app/assets/javascripts/lib/utils/text_markdown.js +++ b/app/assets/javascripts/lib/utils/text_markdown.js @@ -233,7 +233,7 @@ export function insertMarkdownText({ } } else if (tag.indexOf(textPlaceholder) > -1) { textToInsert = tag.replace(textPlaceholder, () => - selected.replace(/\\n/g, '\n').replace(/\/(n|t|r)/g, '\\$1'), + selected.replace(/\\n/g, '\n').replace('%br', '\\n'), ); } else { textToInsert = String(startChar) + tag + selected + (wrap ? tag : ''); diff --git a/app/assets/javascripts/projects/pipelines/charts/index.js b/app/assets/javascripts/projects/pipelines/charts/index.js index 5f5ee44c204..f7ea89068a0 100644 --- a/app/assets/javascripts/projects/pipelines/charts/index.js +++ b/app/assets/javascripts/projects/pipelines/charts/index.js @@ -7,7 +7,7 @@ import ProjectPipelinesCharts from './components/app.vue'; Vue.use(VueApollo); const apolloProvider = new VueApollo({ - defaultClient: createDefaultClient(), + defaultClient: createDefaultClient({}, { assumeImmutableResults: true }), }); const mountPipelineChartsApp = (el) => { diff --git a/app/assets/javascripts/vue_shared/components/markdown/field.vue b/app/assets/javascripts/vue_shared/components/markdown/field.vue index f7891517a1a..1752941f29c 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/field.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/field.vue @@ -16,11 +16,7 @@ import MarkdownHeader from './header.vue'; import MarkdownToolbar from './toolbar.vue'; function cleanUpLine(content) { - return unescape( - stripHtml(content) - .replace(/\\(n|t|r)/g, '/$1') - .replace(/\n/g, ''), - ); + return unescape(stripHtml(content).replace(/\\n/g, '%br').replace(/\n/g, '')); } export default { diff --git a/app/graphql/resolvers/todo_resolver.rb b/app/graphql/resolvers/todo_resolver.rb index 863d402b4d3..f0be1b6e9a5 100644 --- a/app/graphql/resolvers/todo_resolver.rb +++ b/app/graphql/resolvers/todo_resolver.rb @@ -30,6 +30,13 @@ module Resolvers required: false, description: 'Type of the todo.' + before_connection_authorization do |nodes, current_user| + Preloaders::UserMaxAccessLevelInProjectsPreloader.new( + nodes.map(&:project).compact, + current_user + ).execute + end + def resolve(**args) return Todo.none unless current_user.present? && target.present? return Todo.none if target.is_a?(User) && target != current_user diff --git a/app/graphql/types/alert_management/alert_type.rb b/app/graphql/types/alert_management/alert_type.rb index 4bdb476860a..7495d46179c 100644 --- a/app/graphql/types/alert_management/alert_type.rb +++ b/app/graphql/types/alert_management/alert_type.rb @@ -115,9 +115,7 @@ module Types null: true, description: 'Runbook for the alert as defined in alert details.' - field :todos, description: 'To-do items of the current user for the alert.', resolver: Resolvers::TodoResolver do - extension(::Gitlab::Graphql::TodosProjectPermissionPreloader::FieldExtension) - end + field :todos, description: 'To-do items of the current user for the alert.', resolver: Resolvers::TodoResolver field :details_url, GraphQL::Types::String, diff --git a/app/graphql/types/user_interface.rb b/app/graphql/types/user_interface.rb index 47a25e09c7d..6a8c7f35447 100644 --- a/app/graphql/types/user_interface.rb +++ b/app/graphql/types/user_interface.rb @@ -85,9 +85,7 @@ module Types null: true, description: 'Personal namespace of the user.' - field :todos, resolver: Resolvers::TodoResolver, description: 'To-do items of the user.' do - extension(::Gitlab::Graphql::TodosProjectPermissionPreloader::FieldExtension) - end + field :todos, resolver: Resolvers::TodoResolver, description: 'To-do items of the user.' # Merge request field: MRs can be authored, assigned, or assigned-for-review: field :authored_merge_requests, diff --git a/app/views/admin/application_settings/_eks.html.haml b/app/views/admin/application_settings/_eks.html.haml index c44bad132bd..64cc23844e5 100644 --- a/app/views/admin/application_settings/_eks.html.haml +++ b/app/views/admin/application_settings/_eks.html.haml @@ -33,4 +33,4 @@ .form-text.text-muted = _('AWS Secret Access Key. Only required if not using role instance credentials') - = f.submit 'Save changes', class: "gl-button btn btn-confirm" + = f.submit _('Save changes'), class: "gl-button btn btn-confirm" diff --git a/app/views/admin/application_settings/_external_authorization_service_form.html.haml b/app/views/admin/application_settings/_external_authorization_service_form.html.haml index abd182027b1..23484eaec32 100644 --- a/app/views/admin/application_settings/_external_authorization_service_form.html.haml +++ b/app/views/admin/application_settings/_external_authorization_service_form.html.haml @@ -47,4 +47,4 @@ .form-group = f.label :external_authorization_service_default_label, _('Default classification label'), class: 'label-bold' = f.text_field :external_authorization_service_default_label, class: 'form-control gl-form-input' - = f.submit 'Save changes', class: "gl-button btn btn-confirm" + = f.submit _('Save changes'), class: "gl-button btn btn-confirm" diff --git a/app/views/admin/application_settings/_floc.html.haml b/app/views/admin/application_settings/_floc.html.haml index 398064f9730..52833b5cfc2 100644 --- a/app/views/admin/application_settings/_floc.html.haml +++ b/app/views/admin/application_settings/_floc.html.haml @@ -19,4 +19,4 @@ .form-check = f.check_box :floc_enabled, class: 'form-check-input' = f.label :floc_enabled, s_('FloC|Enable FloC (Federated Learning of Cohorts)'), class: 'form-check-label' - = f.submit s_('Save changes'), class: 'gl-button btn btn-confirm' + = f.submit _('Save changes'), class: 'gl-button btn btn-confirm' diff --git a/app/views/admin/application_settings/_gitpod.html.haml b/app/views/admin/application_settings/_gitpod.html.haml index c08b41e8c55..8f99a07b87c 100644 --- a/app/views/admin/application_settings/_gitpod.html.haml +++ b/app/views/admin/application_settings/_gitpod.html.haml @@ -27,4 +27,4 @@ = s_('Gitpod|The URL to your Gitpod instance configured to read your GitLab projects, such as https://gitpod.example.com.') - link_start = ''.html_safe % { url: help_page_path('integration/gitpod', anchor: 'enable-gitpod-in-your-user-settings') } = s_('Gitpod|To use the integration, each user must also enable Gitpod on their GitLab account. %{link_start}How do I enable it?%{link_end} ').html_safe % { link_start: link_start, link_end: ''.html_safe } - = f.submit s_('Save changes'), class: 'gl-button btn btn-confirm' + = f.submit _('Save changes'), class: 'gl-button btn btn-confirm' diff --git a/app/views/admin/application_settings/_import_export_limits.html.haml b/app/views/admin/application_settings/_import_export_limits.html.haml index 820c11279d5..6a49f884a80 100644 --- a/app/views/admin/application_settings/_import_export_limits.html.haml +++ b/app/views/admin/application_settings/_import_export_limits.html.haml @@ -31,4 +31,4 @@ = f.label :group_download_export_limit, _('Max Group Export Download requests per minute per user'), class: 'label-bold' = f.number_field :group_download_export_limit, class: 'form-control gl-form-input' - = f.submit 'Save changes', class: "gl-button btn btn-confirm", data: { qa_selector: 'save_changes_button' } + = f.submit _('Save changes'), class: "gl-button btn btn-confirm", data: { qa_selector: 'save_changes_button' } diff --git a/app/views/admin/application_settings/_issue_limits.html.haml b/app/views/admin/application_settings/_issue_limits.html.haml index 0e1ba8c9c88..663e1485749 100644 --- a/app/views/admin/application_settings/_issue_limits.html.haml +++ b/app/views/admin/application_settings/_issue_limits.html.haml @@ -6,4 +6,4 @@ = f.label :issues_create_limit, 'Max requests per minute per user', class: 'label-bold' = f.number_field :issues_create_limit, class: 'form-control gl-form-input' - = f.submit 'Save changes', class: "gl-button btn btn-confirm", data: { qa_selector: 'save_changes_button' } + = f.submit _('Save changes'), class: "gl-button btn btn-confirm", data: { qa_selector: 'save_changes_button' } diff --git a/app/views/admin/application_settings/_outbound.html.haml b/app/views/admin/application_settings/_outbound.html.haml index d8d105293a1..142a3fbfbd0 100644 --- a/app/views/admin/application_settings/_outbound.html.haml +++ b/app/views/admin/application_settings/_outbound.html.haml @@ -27,4 +27,4 @@ %span.form-text.text-muted = _('Resolves IP addresses once and uses them to submit requests') - = f.submit 'Save changes', class: "gl-button btn btn-confirm", data: { qa_selector: 'save_changes_button' } + = f.submit _('Save changes'), class: "gl-button btn btn-confirm", data: { qa_selector: 'save_changes_button' } diff --git a/app/views/admin/application_settings/_package_registry_limits.html.haml b/app/views/admin/application_settings/_package_registry_limits.html.haml index b1dfd04c55e..47d51da5511 100644 --- a/app/views/admin/application_settings/_package_registry_limits.html.haml +++ b/app/views/admin/application_settings/_package_registry_limits.html.haml @@ -34,4 +34,4 @@ = f.label :throttle_authenticated_packages_api_period_in_seconds, 'Authenticated API rate limit period in seconds', class: 'label-bold' = f.number_field :throttle_authenticated_packages_api_period_in_seconds, class: 'form-control gl-form-input' - = f.submit 'Save changes', class: "gl-button btn btn-confirm", data: { qa_selector: 'save_changes_button' } + = f.submit _('Save changes'), class: "gl-button btn btn-confirm", data: { qa_selector: 'save_changes_button' } diff --git a/app/views/admin/application_settings/_protected_paths.html.haml b/app/views/admin/application_settings/_protected_paths.html.haml index faa675f211d..04b42f42014 100644 --- a/app/views/admin/application_settings/_protected_paths.html.haml +++ b/app/views/admin/application_settings/_protected_paths.html.haml @@ -28,4 +28,4 @@ = _('All paths are relative to the GitLab URL. Do not include %{relative_url_link_start}relative URL%{relative_url_link_end}.').html_safe % { relative_url_link_start: relative_url_link_start, relative_url_link_end: ''.html_safe } = f.text_area :protected_paths_raw, placeholder: '/users/sign_in,/users/password', class: 'form-control gl-form-input', rows: 10 - = f.submit 'Save changes', class: 'gl-button btn btn-confirm' + = f.submit _('Save changes'), class: 'gl-button btn btn-confirm' diff --git a/app/views/projects/hooks/edit.html.haml b/app/views/projects/hooks/edit.html.haml index 226cd7d89b6..e8ea4ad90dc 100644 --- a/app/views/projects/hooks/edit.html.haml +++ b/app/views/projects/hooks/edit.html.haml @@ -10,7 +10,7 @@ = form_for [@project, @hook], as: :hook, url: project_hook_path(@project, @hook) do |f| = render partial: 'shared/web_hooks/form', locals: { form: f, hook: @hook } - = f.submit 'Save changes', class: 'btn gl-button btn-confirm gl-mr-3' + = f.submit _('Save changes'), class: 'btn gl-button btn-confirm gl-mr-3' = render 'shared/web_hooks/test_button', hook: @hook = link_to _('Delete'), project_hook_path(@project, @hook), method: :delete, class: 'btn gl-button btn-danger float-right', data: { confirm: _('Are you sure?') } diff --git a/app/views/projects/tags/releases/edit.html.haml b/app/views/projects/tags/releases/edit.html.haml index 88594209c3b..b03c646178e 100644 --- a/app/views/projects/tags/releases/edit.html.haml +++ b/app/views/projects/tags/releases/edit.html.haml @@ -15,5 +15,5 @@ = render 'shared/notes/hints' .error-alert .gl-mt-5.gl-display-flex - = f.submit 'Save changes', class: 'btn gl-button btn-confirm gl-mr-3' + = f.submit _('Save changes'), class: 'btn gl-button btn-confirm gl-mr-3' = link_to "Cancel", project_tag_path(@project, @tag.name), class: "btn gl-button btn-default btn-cancel" diff --git a/app/views/shared/issuable/_form.html.haml b/app/views/shared/issuable/_form.html.haml index dc93442d6cd..cb03bd4c473 100644 --- a/app/views/shared/issuable/_form.html.haml +++ b/app/views/shared/issuable/_form.html.haml @@ -66,7 +66,7 @@ - if issuable.new_record? = form.submit "Create #{issuable.class.model_name.human.downcase}", class: 'gl-button btn btn-confirm gl-mr-2', data: { qa_selector: 'issuable_create_button' } - else - = form.submit 'Save changes', class: 'gl-button btn btn-confirm gl-mr-2' + = form.submit _('Save changes'), class: 'gl-button btn btn-confirm gl-mr-2' - if issuable.new_record? = link_to _('Cancel'), polymorphic_path([@project, issuable.class]), class: 'btn gl-button btn-default' diff --git a/app/views/shared/labels/_form.html.haml b/app/views/shared/labels/_form.html.haml index 604aac9237c..29f6cbd41dd 100644 --- a/app/views/shared/labels/_form.html.haml +++ b/app/views/shared/labels/_form.html.haml @@ -28,7 +28,7 @@ = render_suggested_colors .form-actions - if @label.persisted? - = f.submit 'Save changes', class: 'btn gl-button btn-confirm js-save-button' + = f.submit _('Save changes'), class: 'btn gl-button btn-confirm js-save-button' - else = f.submit 'Create label', class: 'btn gl-button btn-confirm js-save-button qa-label-create-button' = link_to 'Cancel', back_path, class: 'btn gl-button btn-default btn-cancel' diff --git a/db/migrate/20210819152723_remove_tmp_index_approval_project_rules_scanners.rb b/db/migrate/20210819152723_remove_tmp_index_approval_project_rules_scanners.rb new file mode 100644 index 00000000000..a60141991a6 --- /dev/null +++ b/db/migrate/20210819152723_remove_tmp_index_approval_project_rules_scanners.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RemoveTmpIndexApprovalProjectRulesScanners < ActiveRecord::Migration[6.1] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + INDEX_NAME = 'tmp_index_approval_project_rules_scanners' + + def up + remove_concurrent_index_by_name :approval_project_rules, INDEX_NAME + end + + def down + add_concurrent_index :approval_project_rules, :scanners, name: INDEX_NAME, using: :gin, where: "scanners @> '{cluster_image_scanning}'" + end +end diff --git a/db/schema_migrations/20210819152723 b/db/schema_migrations/20210819152723 new file mode 100644 index 00000000000..b5f4d2795f7 --- /dev/null +++ b/db/schema_migrations/20210819152723 @@ -0,0 +1 @@ +b311fdb0a6e0e10ca3c67b9b2c3d920f8e735f0fd8398fdaa25853e14f88ae97 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 5ebfa6e4d2b..09cef971f04 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -25903,8 +25903,6 @@ CREATE INDEX tmp_idx_deduplicate_vulnerability_occurrences ON vulnerability_occu CREATE INDEX tmp_idx_on_namespaces_delayed_project_removal ON namespaces USING btree (id) WHERE (delayed_project_removal = true); -CREATE INDEX tmp_index_approval_project_rules_scanners ON approval_project_rules USING gin (scanners) WHERE (scanners @> '{cluster_image_scanning}'::text[]); - CREATE INDEX tmp_index_namespaces_empty_traversal_ids_with_child_namespaces ON namespaces USING btree (id) WHERE ((parent_id IS NOT NULL) AND (traversal_ids = '{}'::integer[])); CREATE INDEX tmp_index_namespaces_empty_traversal_ids_with_root_namespaces ON namespaces USING btree (id) WHERE ((parent_id IS NULL) AND (traversal_ids = '{}'::integer[])); diff --git a/doc/.vale/gitlab/spelling-exceptions.txt b/doc/.vale/gitlab/spelling-exceptions.txt index e4deabff66c..012388f60c8 100644 --- a/doc/.vale/gitlab/spelling-exceptions.txt +++ b/doc/.vale/gitlab/spelling-exceptions.txt @@ -90,6 +90,7 @@ callstack callstacks Camo canonicalized +captcha CentOS Certbot changeset diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 2daafbef2fb..4c4ed0ed958 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -1,6 +1,6 @@ --- -stage: Plan -group: Project Management +stage: Ecosystem +group: Integrations info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers --- diff --git a/doc/development/graphql_guide/graphql_pro.md b/doc/development/graphql_guide/graphql_pro.md index ca20d66dd87..3170f0cfdc2 100644 --- a/doc/development/graphql_guide/graphql_pro.md +++ b/doc/development/graphql_guide/graphql_pro.md @@ -1,6 +1,6 @@ --- -stage: Plan -group: Project Management +stage: Ecosystem +group: Integrations info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments --- diff --git a/doc/development/graphql_guide/index.md b/doc/development/graphql_guide/index.md index b8d4b53992e..cc97e41df05 100644 --- a/doc/development/graphql_guide/index.md +++ b/doc/development/graphql_guide/index.md @@ -1,6 +1,6 @@ --- -stage: Plan -group: Project Management +stage: Ecosystem +group: Integrations info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments --- diff --git a/doc/development/graphql_guide/pagination.md b/doc/development/graphql_guide/pagination.md index 5fd2179ea9b..a37c47f1b11 100644 --- a/doc/development/graphql_guide/pagination.md +++ b/doc/development/graphql_guide/pagination.md @@ -1,6 +1,6 @@ --- -stage: Plan -group: Project Management +stage: Ecosystem +group: Integrations info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments --- diff --git a/lib/gitlab/changelog/config.rb b/lib/gitlab/changelog/config.rb index 0538fe68474..d25094d9b37 100644 --- a/lib/gitlab/changelog/config.rb +++ b/lib/gitlab/changelog/config.rb @@ -89,7 +89,7 @@ module Gitlab end def contributor?(user) - @project.team.contributor?(user) + @project.team.contributor?(user&.id) end def category(name) diff --git a/lib/gitlab/graphql/todos_project_permission_preloader/field_extension.rb b/lib/gitlab/graphql/todos_project_permission_preloader/field_extension.rb deleted file mode 100644 index 77f3b1ac71a..00000000000 --- a/lib/gitlab/graphql/todos_project_permission_preloader/field_extension.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Graphql - module TodosProjectPermissionPreloader - class FieldExtension < ::GraphQL::Schema::FieldExtension - def after_resolve(value:, memo:, **rest) - todos = value.to_a - - Preloaders::UserMaxAccessLevelInProjectsPreloader.new( - todos.map(&:project).compact, - current_user(rest) - ).execute - - value - end - - private - - def current_user(options) - options.dig(:context, :current_user) - end - end - end - end -end diff --git a/spec/frontend/lib/utils/text_markdown_spec.js b/spec/frontend/lib/utils/text_markdown_spec.js index 85f3bf26f97..acbf1a975b8 100644 --- a/spec/frontend/lib/utils/text_markdown_spec.js +++ b/spec/frontend/lib/utils/text_markdown_spec.js @@ -100,7 +100,7 @@ describe('init markdown', () => { text: textArea.value, tag: '```suggestion:-0+0\n{text}\n```', blockTag: true, - selected: '# Does not parse the /n currently.', + selected: '# Does not parse the %br currently.', wrap: false, }); diff --git a/spec/frontend/vue_shared/components/markdown/field_spec.js b/spec/frontend/vue_shared/components/markdown/field_spec.js index a01539820f5..76e1a1162ad 100644 --- a/spec/frontend/vue_shared/components/markdown/field_spec.js +++ b/spec/frontend/vue_shared/components/markdown/field_spec.js @@ -250,7 +250,7 @@ describe('Markdown field component', () => { createSubject([{ rich_text: 'hello world\\n' }]); expect(subject.find('[data-testid="markdownHeader"]').props('lineContent')).toBe( - 'hello world/n', + 'hello world%br', ); }); }); diff --git a/spec/lib/gitlab/changelog/config_spec.rb b/spec/lib/gitlab/changelog/config_spec.rb index a464c1e57e5..ff5a084bb86 100644 --- a/spec/lib/gitlab/changelog/config_spec.rb +++ b/spec/lib/gitlab/changelog/config_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe Gitlab::Changelog::Config do + include ProjectForksHelper + let(:project) { build_stubbed(:project) } describe '.from_git' do @@ -66,20 +68,33 @@ RSpec.describe Gitlab::Changelog::Config do end describe '#contributor?' do - it 'returns true if a user is a contributor' do - user = build_stubbed(:author) + let(:project) { create(:project, :public, :repository) } - allow(project.team).to receive(:contributor?).with(user).and_return(true) + context 'when user is a member of project' do + let(:user) { create(:user) } - expect(described_class.new(project).contributor?(user)).to eq(true) + before do + project.add_developer(user) + end + + it { expect(described_class.new(project).contributor?(user)).to eq(false) } end - it "returns true if a user isn't a contributor" do - user = build_stubbed(:author) + context 'when user has at least one merge request merged into default_branch' do + let(:contributor) { create(:user) } + let(:user_without_access) { create(:user) } + let(:user_fork) { fork_project(project, contributor, repository: true) } - allow(project.team).to receive(:contributor?).with(user).and_return(false) + before do + create(:merge_request, :merged, + author: contributor, + target_project: project, + source_project: user_fork, + target_branch: project.default_branch.to_s) + end - expect(described_class.new(project).contributor?(user)).to eq(false) + it { expect(described_class.new(project).contributor?(contributor)).to eq(true) } + it { expect(described_class.new(project).contributor?(user_without_access)).to eq(false) } end end diff --git a/spec/services/repositories/changelog_service_spec.rb b/spec/services/repositories/changelog_service_spec.rb index 02d60f076ca..b547ae17317 100644 --- a/spec/services/repositories/changelog_service_spec.rb +++ b/spec/services/repositories/changelog_service_spec.rb @@ -76,7 +76,7 @@ RSpec.describe Repositories::ChangelogService do recorder = ActiveRecord::QueryRecorder.new { service.execute } changelog = project.repository.blob_at('master', 'CHANGELOG.md')&.data - expect(recorder.count).to eq(11) + expect(recorder.count).to eq(9) expect(changelog).to include('Title 1', 'Title 2') end diff --git a/tooling/graphql/docs/helper.rb b/tooling/graphql/docs/helper.rb index 4a41930df46..ca153c806c4 100644 --- a/tooling/graphql/docs/helper.rb +++ b/tooling/graphql/docs/helper.rb @@ -55,8 +55,8 @@ module Tooling def auto_generated_comment <<-MD.strip_heredoc --- - stage: Plan - group: Project Management + stage: Ecosystem + group: Integrations info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers ---