From dc6fe30d4764a9e566b54c818b66335b33ca2f8d Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 8 Apr 2024 06:10:54 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../integrations/project_test_data.rb | 2 +- app/services/notes/post_process_service.rb | 2 +- app/services/notes/update_service.rb | 2 +- app/views/shared/web_hooks/_form.html.haml | 4 +- .../development/search_index_all_projects.yml | 8 ---- db/docs/boards_epic_list_user_preferences.yml | 21 +++++++++- ...ncident_management_oncall_participants.yml | 18 ++++++++- db/docs/incident_management_oncall_shifts.yml | 18 ++++++++- ...erge_request_context_commit_diff_files.yml | 10 +++++ ..._to_spec_on_catalog_resource_components.rb | 24 +++++++++++ db/schema_migrations/20240403121221 | 1 + doc/administration/admin_area.md | 3 ++ .../advanced_search/elasticsearch.md | 8 +--- .../container_scanning/index.md | 4 +- .../project/integrations/webhook_events.md | 21 ++++++++-- lib/gitlab/data_builder/note.rb | 20 ++++++---- locale/gitlab.pot | 4 +- scripts/lint-doc.sh | 21 ++++++++-- spec/lib/gitlab/data_builder/note_spec.rb | 29 +++++++++++--- ...pec_on_catalog_resource_components_spec.rb | 40 +++++++++++++++++++ .../base_chat_notification_spec.rb | 4 +- .../models/integrations/hangouts_chat_spec.rb | 8 ++-- .../integrations/microsoft_teams_spec.rb | 8 ++-- .../group_mention_service_spec.rb | 2 +- .../chat_integration_shared_examples.rb | 2 +- ...base_slack_notification_shared_examples.rb | 4 +- ...ack_mattermost_notifier_shared_examples.rb | 10 ++--- 27 files changed, 232 insertions(+), 66 deletions(-) delete mode 100644 config/feature_flags/development/search_index_all_projects.yml create mode 100644 db/post_migrate/20240403121221_migrate_inputs_to_spec_on_catalog_resource_components.rb create mode 100644 db/schema_migrations/20240403121221 create mode 100644 spec/migrations/20240403121221_migrate_inputs_to_spec_on_catalog_resource_components_spec.rb diff --git a/app/services/concerns/integrations/project_test_data.rb b/app/services/concerns/integrations/project_test_data.rb index 8fe173ef007..df02b3136ac 100644 --- a/app/services/concerns/integrations/project_test_data.rb +++ b/app/services/concerns/integrations/project_test_data.rb @@ -23,7 +23,7 @@ module Integrations no_data_error(s_('TestHooks|Ensure the project has notes.')) unless note.present? - Gitlab::DataBuilder::Note.build(note, current_user) + Gitlab::DataBuilder::Note.build(note, current_user, :create) end def issues_events_data diff --git a/app/services/notes/post_process_service.rb b/app/services/notes/post_process_service.rb index 6e92a887cdd..b4e5816bf4d 100644 --- a/app/services/notes/post_process_service.rb +++ b/app/services/notes/post_process_service.rb @@ -29,7 +29,7 @@ module Notes end def hook_data - Gitlab::DataBuilder::Note.build(note, note.author) + Gitlab::DataBuilder::Note.build(note, note.author, :create) end def execute_note_hooks diff --git a/app/services/notes/update_service.rb b/app/services/notes/update_service.rb index 3924ccc4745..60e902051c9 100644 --- a/app/services/notes/update_service.rb +++ b/app/services/notes/update_service.rb @@ -102,7 +102,7 @@ module Notes def execute_note_webhook(note) return unless note.project && note.previous_changes.include?('note') - note_data = Gitlab::DataBuilder::Note.build(note, note.author) + note_data = Gitlab::DataBuilder::Note.build(note, note.author, :update) is_confidential = note.confidential?(include_noteable: true) hooks_scope = is_confidential ? :confidential_note_hooks : :note_hooks diff --git a/app/views/shared/web_hooks/_form.html.haml b/app/views/shared/web_hooks/_form.html.haml index 0d3896d8a80..bbd6ec69ba5 100644 --- a/app/views/shared/web_hooks/_form.html.haml +++ b/app/views/shared/web_hooks/_form.html.haml @@ -26,11 +26,11 @@ %li.gl-pb-3 = form.gitlab_ui_checkbox_component :note_events, integration_webhook_event_human_name(:note_events), - help_text: s_('Webhooks|A comment is added to an issue or merge request.') + help_text: s_('Webhooks|A comment is made or edited on an issue or merge request.') %li.gl-pb-3 = form.gitlab_ui_checkbox_component :confidential_note_events, integration_webhook_event_human_name(:confidential_note_events), - help_text: s_('Webhooks|A comment is added to a confidential issue.') + help_text: s_('Webhooks|A comment is made or edited on a confidential issue.') %li.gl-pb-3 = form.gitlab_ui_checkbox_component :issues_events, integration_webhook_event_human_name(:issues_events), diff --git a/config/feature_flags/development/search_index_all_projects.yml b/config/feature_flags/development/search_index_all_projects.yml deleted file mode 100644 index ad81dde6f6e..00000000000 --- a/config/feature_flags/development/search_index_all_projects.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: search_index_all_projects -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/134456 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/432489 -milestone: '16.7' -type: development -group: group::global search -default_enabled: true diff --git a/db/docs/boards_epic_list_user_preferences.yml b/db/docs/boards_epic_list_user_preferences.yml index 32107ac86a2..fd30d0d374d 100644 --- a/db/docs/boards_epic_list_user_preferences.yml +++ b/db/docs/boards_epic_list_user_preferences.yml @@ -4,7 +4,24 @@ classes: - Boards::EpicListUserPreference feature_categories: - portfolio_management -description: Epic board list preferences on a per-user basis, specifically whether the user has collapsed the list or not +description: Epic board list preferences on a per-user basis, specifically whether + the user has collapsed the list or not introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54541 milestone: '13.10' -gitlab_schema: gitlab_main +gitlab_schema: gitlab_main_cell +allow_cross_joins: +- gitlab_main_clusterwide +allow_cross_transactions: +- gitlab_main_clusterwide +allow_cross_foreign_keys: +- gitlab_main_clusterwide +desired_sharding_key: + group_id: + references: namespaces + backfill_via: + parent: + foreign_key: epic_list_id + table: boards_epic_lists + sharding_key: group_id + belongs_to: epic_list + awaiting_backfill_on_parent: true diff --git a/db/docs/incident_management_oncall_participants.yml b/db/docs/incident_management_oncall_participants.yml index 75e2651d234..42783f844b0 100644 --- a/db/docs/incident_management_oncall_participants.yml +++ b/db/docs/incident_management_oncall_participants.yml @@ -8,4 +8,20 @@ feature_categories: description: Persists information about on-call rotation participants introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/49058 milestone: '13.7' -gitlab_schema: gitlab_main +gitlab_schema: gitlab_main_cell +allow_cross_joins: +- gitlab_main_clusterwide +allow_cross_transactions: +- gitlab_main_clusterwide +allow_cross_foreign_keys: +- gitlab_main_clusterwide +desired_sharding_key: + project_id: + references: projects + backfill_via: + parent: + foreign_key: oncall_rotation_id + table: incident_management_oncall_rotations + sharding_key: project_id + belongs_to: rotation + awaiting_backfill_on_parent: true diff --git a/db/docs/incident_management_oncall_shifts.yml b/db/docs/incident_management_oncall_shifts.yml index 2ae33b4430a..9250c35b924 100644 --- a/db/docs/incident_management_oncall_shifts.yml +++ b/db/docs/incident_management_oncall_shifts.yml @@ -8,4 +8,20 @@ feature_categories: description: Tracks past and present on-call shifts introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/49423 milestone: '13.8' -gitlab_schema: gitlab_main +gitlab_schema: gitlab_main_cell +allow_cross_joins: +- gitlab_main_clusterwide +allow_cross_transactions: +- gitlab_main_clusterwide +allow_cross_foreign_keys: +- gitlab_main_clusterwide +desired_sharding_key: + project_id: + references: projects + backfill_via: + parent: + foreign_key: rotation_id + table: incident_management_oncall_rotations + sharding_key: project_id + belongs_to: rotation + awaiting_backfill_on_parent: true diff --git a/db/docs/merge_request_context_commit_diff_files.yml b/db/docs/merge_request_context_commit_diff_files.yml index 451d5078a62..3d7bb85e2f9 100644 --- a/db/docs/merge_request_context_commit_diff_files.yml +++ b/db/docs/merge_request_context_commit_diff_files.yml @@ -8,3 +8,13 @@ description: Stores diffs data for merge request context commits introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/23701 milestone: '12.8' gitlab_schema: gitlab_main_cell +desired_sharding_key: + project_id: + references: projects + backfill_via: + parent: + foreign_key: merge_request_context_commit_id + table: merge_request_context_commits + sharding_key: project_id + belongs_to: merge_request_context_commit + awaiting_backfill_on_parent: true diff --git a/db/post_migrate/20240403121221_migrate_inputs_to_spec_on_catalog_resource_components.rb b/db/post_migrate/20240403121221_migrate_inputs_to_spec_on_catalog_resource_components.rb new file mode 100644 index 00000000000..414a20df3f1 --- /dev/null +++ b/db/post_migrate/20240403121221_migrate_inputs_to_spec_on_catalog_resource_components.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class MigrateInputsToSpecOnCatalogResourceComponents < Gitlab::Database::Migration[2.2] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + milestone '16.11' + + disable_ddl_transaction! + + def up + each_batch_range('catalog_resource_components') do |min, max| + execute <<~SQL + UPDATE catalog_resource_components + SET spec = jsonb_set('{}'::jsonb, '{inputs}', inputs::jsonb) + WHERE id BETWEEN #{min} AND #{max} + AND spec = '{}' AND inputs <> '{}' + SQL + end + end + + def down + # no-op + end +end diff --git a/db/schema_migrations/20240403121221 b/db/schema_migrations/20240403121221 new file mode 100644 index 00000000000..47b514cabea --- /dev/null +++ b/db/schema_migrations/20240403121221 @@ -0,0 +1 @@ +ad8357914a0be5759d5ee1a4366cd56c0eed9f5d63ad5f75db219d089e9c465e \ No newline at end of file diff --git a/doc/administration/admin_area.md b/doc/administration/admin_area.md index edd2985451b..e6c5484ab11 100644 --- a/doc/administration/admin_area.md +++ b/doc/administration/admin_area.md @@ -17,6 +17,9 @@ self-managed instances. If you are an administrator, to access the Admin Area: - In GitLab 16.1 and later: on the left sidebar, select **Search or go to**, then select **Admin Area**. - In GitLab 16.0 and earlier: on the top bar, select **Main menu > Admin**. +If the GitLab instance uses Admin Mode, you must [enable Admin Mode for your session](settings/sign_in_restrictions.md#turn-on-admin-mode-for-your-session) before +the **Admin Area** button is visible. + NOTE: Only administrators can access the Admin Area. diff --git a/doc/integration/advanced_search/elasticsearch.md b/doc/integration/advanced_search/elasticsearch.md index a6acbfbce9c..d59776aed9b 100644 --- a/doc/integration/advanced_search/elasticsearch.md +++ b/doc/integration/advanced_search/elasticsearch.md @@ -399,13 +399,7 @@ from the Elasticsearch index as expected. #### All project records are indexed > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/428070) in GitLab 16.7 [with a flag](../../administration/feature_flags.md) named `search_index_all_projects`. Disabled by default. -> - [Enabled on GitLab.com](https://gitlab.com/gitlab-org/gitlab/-/issues/432489) in GitLab 16.9. -> - [Enabled on self-managed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145300) in GitLab 16.10. - -FLAG: -On self-managed GitLab, by default this feature is available. -To hide the feature, an administrator can [disable the feature flag](../../administration/feature_flags.md) named `search_index_all_projects`. -On GitLab.com, this feature is available. On GitLab Dedicated, this feature is not available. +> - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/148111) in GitLab 16.11. Feature flag `search_index_all_projects` removed. When you select the **Limit the amount of namespace and project data to index** checkbox: diff --git a/doc/user/application_security/container_scanning/index.md b/doc/user/application_security/container_scanning/index.md index a4462f7ca82..878b9997ec6 100644 --- a/doc/user/application_security/container_scanning/index.md +++ b/doc/user/application_security/container_scanning/index.md @@ -42,7 +42,9 @@ GitLab integrates with open-source tools for vulnerability static analysis in co WARNING: Support for Grype was [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/439164) in GitLab -16.9 and is planned for removal in 17.0. Use Trivy instead. +16.9 and is planned for removal in 17.0. Use Trivy instead. +In GitLab 17.0 and later, the Grype analyzer will no longer be maintained, except for limited fixes as explained in our [statement of support](https://about.gitlab.com/support/statement-of-support/#version-support). +The existing current major version for the Grype analyzer image will continue to be updated with the latest advisory database, and operating system packages until GitLab 19.0, at which point the analyzer will stop working. To integrate GitLab with security scanners other than those listed here, see [Security scanner integration](../../../development/integrations/secure.md). diff --git a/doc/user/project/integrations/webhook_events.md b/doc/user/project/integrations/webhook_events.md index 351ae566e93..78209c55118 100644 --- a/doc/user/project/integrations/webhook_events.md +++ b/doc/user/project/integrations/webhook_events.md @@ -21,7 +21,7 @@ Event type | Trigger [Push event](#push-events) | A push is made to the repository. [Tag event](#tag-events) | Tags are created or deleted in the repository. [Issue event](#issue-events) | A new issue is created or an existing issue is updated, closed, or reopened. -[Comment event](#comment-events) | A new comment is made on commits, merge requests, issues, and code snippets. +[Comment event](#comment-events) | A new comment is made or edited on commits, merge requests, issues, and code snippets. 1 [Merge request event](#merge-request-events) | A merge request is created, updated, merged, or closed, or a commit is added in the source branch. [Wiki page event](#wiki-page-events) | A wiki page is created, updated, or deleted. [Pipeline event](#pipeline-events) | A pipeline status changes. @@ -32,6 +32,10 @@ Event type | Trigger [Emoji event](#emoji-events) | An emoji reaction is added or removed. [Project or group access token event](#project-and-group-access-token-events) | A project or group access token will expire in seven days. +**Footnotes:** + +1. Comment events triggered when the comment is edited [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/127169) in GitLab 16.11. + **Events triggered for group webhooks only:** Event type | Trigger @@ -380,20 +384,27 @@ Payload example: ## Comment events -Comment events are triggered when a new comment is made on commits, +> - `object_attributes.action` property [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/147856) in GitLab 16.11. + +Comment events are triggered when a new comment is made or edited on commits, merge requests, issues, and code snippets. The note data is stored in `object_attributes` (for example, `note` or `noteable_type`). The payload includes information about the target of the comment. For example, a comment on an issue includes specific issue information under the `issue` key. -The valid target types are: +The available target types are: - `commit` - `merge_request` - `issue` - `snippet` +The available values for `object_attributes.action` in the payload are: + +- `create` +- `update` + ### Comment on a commit Request header: @@ -462,6 +473,7 @@ Payload example: "renamed_file": false, "deleted_file": false }, + "action": "create", "url": "http://example.com/gitlab-org/gitlab-test/commit/cfe32cf61b73a0d5e9f13e774abde7ff789b1660#note_1243" }, "commit": { @@ -536,6 +548,7 @@ Payload example: "noteable_id": 7, "system": false, "st_diff": null, + "action": "create", "url": "http://example.com/gitlab-org/gitlab-test/merge_requests/1#note_1244" }, "merge_request": { @@ -697,6 +710,7 @@ Payload example: "noteable_id": 92, "system": false, "st_diff": null, + "action": "create", "url": "http://example.com/gitlab-org/gitlab-test/issues/17#note_1241" }, "issue": { @@ -803,6 +817,7 @@ Payload example: "noteable_id": 53, "system": false, "st_diff": null, + "action": "create", "url": "http://example.com/gitlab-org/gitlab-test/-/snippets/53#note_1245" }, "snippet": { diff --git a/lib/gitlab/data_builder/note.rb b/lib/gitlab/data_builder/note.rb index dec583f5a42..57615c72227 100644 --- a/lib/gitlab/data_builder/note.rb +++ b/lib/gitlab/data_builder/note.rb @@ -5,6 +5,8 @@ module Gitlab module Note extend self + VALID_ACTIONS = %i[create update].freeze + # Produce a hash of post-receive data # # For all notes: @@ -36,9 +38,11 @@ module Gitlab # - merge_request # - snippet # - def build(note, user) + def build(note, user, action) + raise ArgumentError, 'invalid action' unless action.in?(VALID_ACTIONS) + project = note.project - data = build_base_data(project, user, note) + data = build_base_data(project, user, note, action) if note.for_commit? data[:commit] = build_data_for_commit(project, user, note) @@ -53,22 +57,22 @@ module Gitlab data end - def build_base_data(project, user, note) + def build_base_data(project, user, note, action) event_type = note.confidential?(include_noteable: true) ? 'confidential_note' : 'note' - base_data = { + { object_kind: "note", event_type: event_type, user: user.hook_attrs, project_id: project.id, project: project.hook_attrs, - object_attributes: note.hook_attrs, + object_attributes: note.hook_attrs.merge( + action: action.to_s, + url: Gitlab::UrlBuilder.build(note) + ), # DEPRECATED repository: project.hook_attrs.slice(:name, :url, :description, :homepage) } - - base_data[:object_attributes][:url] = Gitlab::UrlBuilder.build(note) - base_data end def build_data_for_commit(project, user, note) diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 8ca83780943..98872cd1fc2 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -57065,10 +57065,10 @@ msgstr "" msgid "Webhooks|+ Mask another portion of URL" msgstr "" -msgid "Webhooks|A comment is added to a confidential issue." +msgid "Webhooks|A comment is made or edited on a confidential issue." msgstr "" -msgid "Webhooks|A comment is added to an issue or merge request." +msgid "Webhooks|A comment is made or edited on an issue or merge request." msgstr "" msgid "Webhooks|A confidential issue is created, updated, closed, or reopened." diff --git a/scripts/lint-doc.sh b/scripts/lint-doc.sh index 254607be4e7..53ebd087943 100755 --- a/scripts/lint-doc.sh +++ b/scripts/lint-doc.sh @@ -90,11 +90,11 @@ fi # Do not use dashes (-) in directory names, use underscores (_) instead. # Number of directories with dashes as of 2021-09-17 -NUMBER_DASHES=2 -FIND_DASHES=$(find doc -type d -name "*-*" | wc -l) +DIR_NUMBER_DASHES=2 +DIR_FIND_DASHES=$(find doc -type d -name "*-*" | wc -l) # shellcheck disable=2059 printf "${COLOR_GREEN}INFO: Checking for directory names containing dashes...${COLOR_RESET}\n" -if [ "${FIND_DASHES}" -ne $NUMBER_DASHES ] +if [ "${DIR_FIND_DASHES}" -ne $DIR_NUMBER_DASHES ] then # shellcheck disable=2059 printf "${COLOR_RED}ERROR: The number of directory names containing dashes has changed!${COLOR_RESET} Use underscores instead of dashes for the directory names.\n" >&2 @@ -103,6 +103,21 @@ then ((ERRORCODE++)) fi +# Do not use dashes (-) in filenames, use underscores (_) instead. +# Number of filenames with dashes as of 2024-03-29 +FILE_NUMBER_DASHES=73 +FILE_FIND_DASHES=$(find doc -type f -name "*-*.md" | wc -l) +# shellcheck disable=2059 +printf "${COLOR_GREEN}INFO: Checking for filenames containing dashes...${COLOR_RESET}\n" +if [ "${FILE_FIND_DASHES}" -ne $FILE_NUMBER_DASHES ] +then + # shellcheck disable=2059 + printf "${COLOR_RED}ERROR: The number of filenames containing dashes has changed!${COLOR_RESET} Use underscores instead of dashes for the filenames.\n" >&2 + printf "If removing a file containing dashes, update the filename NUMBER_DASHES in lint-doc.sh.\n" >&2 + printf "https://docs.gitlab.com/ee/development/documentation/site_architecture/folder_structure.html#work-with-directories-and-files\n" + ((ERRORCODE++)) +fi + # Do not use uppercase letters in directory and file names, use all lowercase instead. # (find always returns 0, so we use the grep hack https://serverfault.com/a/225827) FIND_UPPERCASE_DIRS=$(find doc -type d -name "*[[:upper:]]*") diff --git a/spec/lib/gitlab/data_builder/note_spec.rb b/spec/lib/gitlab/data_builder/note_spec.rb index 8e8b8ce6681..ea38d2d5144 100644 --- a/spec/lib/gitlab/data_builder/note_spec.rb +++ b/spec/lib/gitlab/data_builder/note_spec.rb @@ -2,18 +2,19 @@ require 'spec_helper' -RSpec.describe Gitlab::DataBuilder::Note do - let(:project) { create(:project, :repository) } - let(:user) { create(:user) } - let(:data) { described_class.build(note, user) } +RSpec.describe Gitlab::DataBuilder::Note, feature_category: :webhooks do + let_it_be(:project) { create(:project, :repository) } + let_it_be(:user) { create(:user) } + let(:action) { :create } + let(:data) { described_class.build(note, user, action) } let(:fixed_time) { Time.at(1425600000) } # Avoid time precision errors shared_examples 'includes general data' do specify do expect(data).to have_key(:object_attributes) expect(data[:object_attributes]).to have_key(:url) - expect(data[:object_attributes][:url]) - .to eq(Gitlab::UrlBuilder.build(note)) + expect(data[:object_attributes][:url]).to eq(Gitlab::UrlBuilder.build(note)) + expect(data[:object_attributes][:action]).to eq('create') expect(data[:object_kind]).to eq('note') expect(data[:user]).to eq(user.hook_attrs) end @@ -158,4 +159,20 @@ RSpec.describe Gitlab::DataBuilder::Note do include_examples 'project hook data' include_examples 'deprecated repository hook data' end + + describe 'object_attributes.action value' do + let_it_be(:note) { create(:note, project: project) } + + describe 'when action is `:update`' do + let(:action) { :update } + + it { expect(data[:object_attributes][:action]).to eq('update') } + end + + describe 'when action is invalid' do + let(:action) { :invalid } + + it { expect { data }.to raise_error(ArgumentError) } + end + end end diff --git a/spec/migrations/20240403121221_migrate_inputs_to_spec_on_catalog_resource_components_spec.rb b/spec/migrations/20240403121221_migrate_inputs_to_spec_on_catalog_resource_components_spec.rb new file mode 100644 index 00000000000..07fe884869b --- /dev/null +++ b/spec/migrations/20240403121221_migrate_inputs_to_spec_on_catalog_resource_components_spec.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! + +RSpec.describe MigrateInputsToSpecOnCatalogResourceComponents, feature_category: :pipeline_composition do + let(:namespaces_table) { table(:namespaces) } + let(:projects_table) { table(:projects) } + let(:resources_table) { table(:catalog_resources) } + let(:releases_table) { table(:releases) } + let(:versions_table) { table(:catalog_resource_versions) } + let(:components_table) { table(:catalog_resource_components) } + + it 'fills in the spec column for components with an inputs value and no spec value', :aggregate_failures do + namespace = namespaces_table.create!(name: 'test', path: 'test') + project = projects_table.create!(namespace_id: namespace.id, project_namespace_id: namespace.id) + resource = resources_table.create!(project_id: project.id) + release = releases_table.create!(released_at: Time.current, tag: 'test') + version = versions_table.create!(release_id: release.id, catalog_resource_id: resource.id, project_id: project.id) + + component_needs_spec = components_table.create!( + name: 'test', inputs: { test_input: nil }, spec: {}, + version_id: version.id, project_id: project.id, catalog_resource_id: resource.id + ) + component_has_spec = components_table.create!( + name: 'test', spec: { inputs: { test_input: nil } }, inputs: {}, + version_id: version.id, project_id: project.id, catalog_resource_id: resource.id + ) + component_no_spec = components_table.create!( + name: 'test', spec: {}, inputs: {}, + version_id: version.id, project_id: project.id, catalog_resource_id: resource.id + ) + + migrate! + + expect(component_needs_spec.reload.spec).to eq({ 'inputs' => { 'test_input' => nil } }) + expect(component_has_spec.reload.spec).to eq({ 'inputs' => { 'test_input' => nil } }) + expect(component_no_spec.reload.spec).to be_empty + end +end diff --git a/spec/models/integrations/base_chat_notification_spec.rb b/spec/models/integrations/base_chat_notification_spec.rb index 9ad37f40fbc..bf0be1b4854 100644 --- a/spec/models/integrations/base_chat_notification_spec.rb +++ b/spec/models/integrations/base_chat_notification_spec.rb @@ -118,7 +118,7 @@ RSpec.describe Integrations::BaseChatNotification, feature_category: :integratio let_it_be(:issue) { create(:labeled_issue, project: project, labels: [label, label_2, label_3]) } let_it_be(:note) { create(:note, noteable: issue, project: project) } - let(:data) { Gitlab::DataBuilder::Note.build(note, user) } + let(:data) { Gitlab::DataBuilder::Note.build(note, user, :create) } shared_examples 'notifies the chat integration' do specify do @@ -262,7 +262,7 @@ RSpec.describe Integrations::BaseChatNotification, feature_category: :integratio context 'labels are distributed on multiple objects' do let(:label_filter) { '~Bug, ~Backend' } let(:data) do - Gitlab::DataBuilder::Note.build(note, user).merge({ + Gitlab::DataBuilder::Note.build(note, user, :create).merge({ issue: { labels: [ { title: 'Bug' } diff --git a/spec/models/integrations/hangouts_chat_spec.rb b/spec/models/integrations/hangouts_chat_spec.rb index 1dd21c88fb7..99d0a2cea7b 100644 --- a/spec/models/integrations/hangouts_chat_spec.rb +++ b/spec/models/integrations/hangouts_chat_spec.rb @@ -144,7 +144,7 @@ RSpec.describe Integrations::HangoutsChat, feature_category: :integrations do end it "adds thread key" do - data = Gitlab::DataBuilder::Note.build(commit_note, user) + data = Gitlab::DataBuilder::Note.build(commit_note, user, :create) WebMock.stub_request(:post, webhook_url_regex) .with { |request| expect(thread_key_from_request(request)).to match(/commit .*?/) } @@ -163,7 +163,7 @@ RSpec.describe Integrations::HangoutsChat, feature_category: :integrations do end it "adds thread key" do - data = Gitlab::DataBuilder::Note.build(merge_request_note, user) + data = Gitlab::DataBuilder::Note.build(merge_request_note, user, :create) WebMock.stub_request(:post, webhook_url_regex) .with { |request| expect(thread_key_from_request(request)).to match(/merge request .*?/) } @@ -182,7 +182,7 @@ RSpec.describe Integrations::HangoutsChat, feature_category: :integrations do end it "adds thread key" do - data = Gitlab::DataBuilder::Note.build(issue_note, user) + data = Gitlab::DataBuilder::Note.build(issue_note, user, :create) WebMock.stub_request(:post, webhook_url_regex) .with { |request| expect(thread_key_from_request(request)).to match(/issue .*?/) } @@ -201,7 +201,7 @@ RSpec.describe Integrations::HangoutsChat, feature_category: :integrations do end it "adds thread key" do - data = Gitlab::DataBuilder::Note.build(snippet_note, user) + data = Gitlab::DataBuilder::Note.build(snippet_note, user, :create) WebMock.stub_request(:post, webhook_url_regex) .with { |request| expect(thread_key_from_request(request)).to match(/snippet .*?/) } diff --git a/spec/models/integrations/microsoft_teams_spec.rb b/spec/models/integrations/microsoft_teams_spec.rb index 4f5b4daad42..176fa2db298 100644 --- a/spec/models/integrations/microsoft_teams_spec.rb +++ b/spec/models/integrations/microsoft_teams_spec.rb @@ -143,7 +143,7 @@ RSpec.describe Integrations::MicrosoftTeams, feature_category: :integrations do end it "calls Microsoft Teams API for commit comment events" do - data = Gitlab::DataBuilder::Note.build(commit_note, user) + data = Gitlab::DataBuilder::Note.build(commit_note, user, :create) chat_integration.execute(data) @@ -157,7 +157,7 @@ RSpec.describe Integrations::MicrosoftTeams, feature_category: :integrations do end it "calls Microsoft Teams API for merge request comment events" do - data = Gitlab::DataBuilder::Note.build(merge_request_note, user) + data = Gitlab::DataBuilder::Note.build(merge_request_note, user, :create) chat_integration.execute(data) @@ -171,7 +171,7 @@ RSpec.describe Integrations::MicrosoftTeams, feature_category: :integrations do end it "calls Microsoft Teams API for issue comment events" do - data = Gitlab::DataBuilder::Note.build(issue_note, user) + data = Gitlab::DataBuilder::Note.build(issue_note, user, :create) chat_integration.execute(data) @@ -185,7 +185,7 @@ RSpec.describe Integrations::MicrosoftTeams, feature_category: :integrations do end it "calls Microsoft Teams API for snippet comment events" do - data = Gitlab::DataBuilder::Note.build(snippet_note, user) + data = Gitlab::DataBuilder::Note.build(snippet_note, user, :create) chat_integration.execute(data) diff --git a/spec/services/integrations/group_mention_service_spec.rb b/spec/services/integrations/group_mention_service_spec.rb index 72d53ce6d06..2891b985282 100644 --- a/spec/services/integrations/group_mention_service_spec.rb +++ b/spec/services/integrations/group_mention_service_spec.rb @@ -93,7 +93,7 @@ RSpec.describe Integrations::GroupMentionService, feature_category: :integration end context 'for issue notes' do - let(:hook_data) { Gitlab::DataBuilder::Note.build(mentionable, mentionable.author) } + let(:hook_data) { Gitlab::DataBuilder::Note.build(mentionable, mentionable.author, :create) } let(:is_confidential) { mentionable.confidential?(include_noteable: true) } context 'in public projects' do diff --git a/spec/support/shared_examples/models/chat_integration_shared_examples.rb b/spec/support/shared_examples/models/chat_integration_shared_examples.rb index 0ff2c135972..824cf5eaa10 100644 --- a/spec/support/shared_examples/models/chat_integration_shared_examples.rb +++ b/spec/support/shared_examples/models/chat_integration_shared_examples.rb @@ -223,7 +223,7 @@ RSpec.shared_examples "chat integration" do |integration_name, supports_deployme end context "with note events" do - let(:sample_data) { Gitlab::DataBuilder::Note.build(note, user) } + let(:sample_data) { Gitlab::DataBuilder::Note.build(note, user, :create) } context "with commit comment" do let_it_be(:note) do diff --git a/spec/support/shared_examples/models/concerns/integrations/base_slack_notification_shared_examples.rb b/spec/support/shared_examples/models/concerns/integrations/base_slack_notification_shared_examples.rb index d05c29c39c3..869a6a75c90 100644 --- a/spec/support/shared_examples/models/concerns/integrations/base_slack_notification_shared_examples.rb +++ b/spec/support/shared_examples/models/concerns/integrations/base_slack_notification_shared_examples.rb @@ -105,7 +105,7 @@ RSpec.shared_examples Integrations::BaseSlackNotification do |factory:| context 'for note notification' do let_it_be(:issue_note) { create(:note_on_issue, project: project, note: 'issue note') } - let(:data) { Gitlab::DataBuilder::Note.build(issue_note, user) } + let(:data) { Gitlab::DataBuilder::Note.build(issue_note, user, :create) } it_behaves_like 'increases the usage data counter', :note end @@ -126,7 +126,7 @@ RSpec.shared_examples Integrations::BaseSlackNotification do |factory:| create(:note_on_issue, project: project, note: 'issue note', confidential: true) end - let(:data) { Gitlab::DataBuilder::Note.build(confidential_issue_note, user) } + let(:data) { Gitlab::DataBuilder::Note.build(confidential_issue_note, user, :create) } it_behaves_like 'increases the usage data counter', :confidential_note end diff --git a/spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb b/spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb index 9e5b5ecfb48..e409617311b 100644 --- a/spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb +++ b/spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb @@ -238,7 +238,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |integration_name context 'note event' do let_it_be(:issue_note) { create(:note_on_issue, project: project, note: "issue note") } - let(:data) { Gitlab::DataBuilder::Note.build(issue_note, user) } + let(:data) { Gitlab::DataBuilder::Note.build(issue_note, user, :create) } it_behaves_like 'calls the integration API with the event message', /commented on issue/ @@ -475,7 +475,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |integration_name end let(:data) do - Gitlab::DataBuilder::Note.build(commit_note, user) + Gitlab::DataBuilder::Note.build(commit_note, user, :create) end it_behaves_like "triggered #{integration_name} integration", event_type: "commit comment" @@ -487,7 +487,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |integration_name end let(:data) do - Gitlab::DataBuilder::Note.build(merge_request_note, user) + Gitlab::DataBuilder::Note.build(merge_request_note, user, :create) end it_behaves_like "triggered #{integration_name} integration", event_type: "merge request comment" @@ -499,7 +499,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |integration_name end let(:data) do - Gitlab::DataBuilder::Note.build(issue_note, user) + Gitlab::DataBuilder::Note.build(issue_note, user, :create) end it_behaves_like "triggered #{integration_name} integration", event_type: "issue comment" @@ -511,7 +511,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |integration_name end let(:data) do - Gitlab::DataBuilder::Note.build(snippet_note, user) + Gitlab::DataBuilder::Note.build(snippet_note, user, :create) end it_behaves_like "triggered #{integration_name} integration", event_type: "snippet comment"