summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-12 06:10:23 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-12 06:10:23 +0000
commita20bd972bcc5e653641e6291a80957ce85958988 (patch)
tree8ecd6106daa1d4e36a768d491385a747a0e7f44a
parentf78f3d867871ce9ad79e5fcb8e4e3e8ffda37200 (diff)
downloadgitlab-ce-a20bd972bcc5e653641e6291a80957ce85958988.tar.gz
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--.gitlab/ci/docs.gitlab-ci.yml13
-rw-r--r--.gitlab/ci/rules.gitlab-ci.yml12
-rw-r--r--data/deprecations/templates/_deprecation_template.md.erb16
-rw-r--r--doc/update/deprecations.md16
-rw-r--r--lib/gitlab/merge_requests/merge_commit_message.rb1
-rw-r--r--lib/tasks/gitlab/docs/compile_deprecations.rake2
-rw-r--r--qa/qa/specs/helpers/context_selector.rb4
-rw-r--r--qa/spec/specs/helpers/context_selector_spec.rb18
-rw-r--r--spec/controllers/groups/settings/integrations_controller_spec.rb4
-rw-r--r--spec/controllers/projects/hooks_controller_spec.rb2
-rw-r--r--spec/controllers/projects/services_controller_spec.rb4
-rw-r--r--spec/factories/integrations.rb5
-rw-r--r--spec/features/projects/integrations/user_uses_inherited_settings_spec.rb2
-rw-r--r--spec/graphql/types/alert_management/prometheus_integration_type_spec.rb2
-rw-r--r--spec/lib/gitlab/merge_requests/merge_commit_message_spec.rb33
-rw-r--r--spec/models/concerns/has_integrations_spec.rb2
-rw-r--r--spec/models/group_spec.rb4
-rw-r--r--spec/models/integration_spec.rb18
-rw-r--r--spec/services/admin/propagate_integration_service_spec.rb4
-rw-r--r--spec/services/bulk_create_integration_service_spec.rb8
-rw-r--r--spec/services/bulk_update_integration_service_spec.rb25
-rw-r--r--spec/services/groups/create_service_spec.rb4
-rw-r--r--spec/services/groups/transfer_service_spec.rb6
-rw-r--r--spec/services/projects/create_service_spec.rb4
-rw-r--r--spec/services/projects/transfer_service_spec.rb2
-rw-r--r--spec/support/helpers/graphql_helpers.rb3
-rw-r--r--spec/support/shared_examples/controllers/create_notes_rate_limit_shared_examples.rb58
-rw-r--r--spec/support/shared_examples/graphql/notes_creation_shared_examples.rb26
-rw-r--r--spec/support/shared_examples/requests/api/notes_shared_examples.rb2
-rw-r--r--spec/workers/propagate_integration_group_worker_spec.rb2
-rw-r--r--spec/workers/propagate_integration_inherit_descendant_worker_spec.rb4
-rw-r--r--spec/workers/propagate_integration_project_worker_spec.rb2
32 files changed, 198 insertions, 110 deletions
diff --git a/.gitlab/ci/docs.gitlab-ci.yml b/.gitlab/ci/docs.gitlab-ci.yml
index eedfea994c4..6aa3d533315 100644
--- a/.gitlab/ci/docs.gitlab-ci.yml
+++ b/.gitlab/ci/docs.gitlab-ci.yml
@@ -76,3 +76,16 @@ ui-docs-links lint:
needs: []
script:
- bundle exec haml-lint -i DocumentationLinks
+
+docs-lint deprecations:
+ variables:
+ SETUP_DB: "false"
+ extends:
+ - .default-retry
+ - .rails-cache
+ - .default-before_script
+ - .docs:rules:deprecations
+ stage: lint
+ needs: []
+ script:
+ - bundle exec rake gitlab:docs:check_deprecations
diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml
index f024468f5ac..3694c6d2c6b 100644
--- a/.gitlab/ci/rules.gitlab-ci.yml
+++ b/.gitlab/ci/rules.gitlab-ci.yml
@@ -165,6 +165,13 @@
- ".markdownlint.yml"
- "scripts/lint-doc.sh"
+.docs-deprecations-patterns: &docs-deprecations-patterns
+ - "doc/deprecations/index.md"
+ - "data/deprecations/*.yml"
+ - "data/deprecations/templates/_deprecation_template.md.erb"
+ - "lib/tasks/gitlab/docs/compile_deprecations.rake"
+ - "tooling/deprecations/docs.rb"
+
.bundler-patterns: &bundler-patterns
- '{Gemfile.lock,*/Gemfile.lock,*/*/Gemfile.lock}'
@@ -530,6 +537,11 @@
changes: *docs-patterns
when: on_success
+.docs:rules:deprecations:
+ rules:
+ - <<: *if-default-refs
+ changes: *docs-deprecations-patterns
+
##################
# GraphQL rules #
##################
diff --git a/data/deprecations/templates/_deprecation_template.md.erb b/data/deprecations/templates/_deprecation_template.md.erb
index 82f9c25386b..80b860b367f 100644
--- a/data/deprecations/templates/_deprecation_template.md.erb
+++ b/data/deprecations/templates/_deprecation_template.md.erb
@@ -17,15 +17,23 @@ sole discretion of GitLab Inc.
<!-- vale off -->
<!--
+DO NOT EDIT THIS PAGE DIRECTLY
+
This page is automatically generated from the YAML files in `/data/deprecations` by the rake task
located at `lib/tasks/gitlab/docs/compile_deprecations.rake`.
-Do not edit this page directly.
+For deprecation authors (usually Product Managers and Engineering Managers):
+
+- To add a deprecation, use the example.yml file in `/data/deprecations/templates` as a template.
+- For more information about authoring deprecations, check the the deprecation item guidance:
+ https://about.gitlab.com/handbook/marketing/blog/release-posts/#creating-a-deprecation-entry
-To add a deprecation, use the example.yml file in `/data/deprecations/templates` as a template.
+For deprecation reviewers (Technical Writers only):
-To update this doc, run `bin/rake gitlab:docs:compile_deprecations`.
-To verify this doc is up to date, run `bin/rake gitlab:docs:check_deprecations`
+- To update the deprecation doc, run: `bin/rake gitlab:docs:compile_deprecations`
+- To verify the deprecations doc is up to date, run: `bin/rake gitlab:docs:check_deprecations`
+- For more information about updating the deprecation doc, see the deprecation doc update guidance:
+ https://about.gitlab.com/handbook/marketing/blog/release-posts/#update-the-deprecations-doc
-->
<% if milestones.any? -%>
<%- milestones.each do |milestone| %>
diff --git a/doc/update/deprecations.md b/doc/update/deprecations.md
index 37de62be387..027e0568219 100644
--- a/doc/update/deprecations.md
+++ b/doc/update/deprecations.md
@@ -17,15 +17,23 @@ sole discretion of GitLab Inc.
<!-- vale off -->
<!--
+DO NOT EDIT THIS PAGE DIRECTLY
+
This page is automatically generated from the YAML files in `/data/deprecations` by the rake task
located at `lib/tasks/gitlab/docs/compile_deprecations.rake`.
-Do not edit this page directly.
+For deprecation authors (usually Product Managers and Engineering Managers):
+
+- To add a deprecation, use the example.yml file in `/data/deprecations/templates` as a template.
+- For more information about authoring deprecations, check the the deprecation item guidance:
+ https://about.gitlab.com/handbook/marketing/blog/release-posts/#creating-a-deprecation-entry
-To add a deprecation, use the example.yml file in `/data/deprecations/templates` as a template.
+For deprecation reviewers (Technical Writers only):
-To update this doc, run `bin/rake gitlab:docs:compile_deprecations`.
-To verify this doc is up to date, run `bin/rake gitlab:docs:check_deprecations`
+- To update the deprecation doc, run: `bin/rake gitlab:docs:compile_deprecations`
+- To verify the deprecations doc is up to date, run: `bin/rake gitlab:docs:check_deprecations`
+- For more information about updating the deprecation doc, see the deprecation doc update guidance:
+ https://about.gitlab.com/handbook/marketing/blog/release-posts/#update-the-deprecations-doc
-->
## 14.4
diff --git a/lib/gitlab/merge_requests/merge_commit_message.rb b/lib/gitlab/merge_requests/merge_commit_message.rb
index f3e3988b55d..2a6a7859b33 100644
--- a/lib/gitlab/merge_requests/merge_commit_message.rb
+++ b/lib/gitlab/merge_requests/merge_commit_message.rb
@@ -10,6 +10,7 @@ module Gitlab
return unless @merge_request.target_project.merge_commit_template.present?
message = @merge_request.target_project.merge_commit_template
+ message = message.delete("\r")
# Remove placeholders that correspond to empty values and are the last word in the line
# along with all whitespace characters preceding them.
diff --git a/lib/tasks/gitlab/docs/compile_deprecations.rake b/lib/tasks/gitlab/docs/compile_deprecations.rake
index 0fd43775015..dc9788cb0b2 100644
--- a/lib/tasks/gitlab/docs/compile_deprecations.rake
+++ b/lib/tasks/gitlab/docs/compile_deprecations.rake
@@ -21,7 +21,7 @@ namespace :gitlab do
if doc == contents
puts "Deprecations doc is up to date."
else
- format_output('Deprecations doc is outdated! Please update it by running `bundle exec rake gitlab:docs:compile_deprecations`.')
+ format_output('Deprecations doc is outdated! You (or your technical writer) can update it by running `bin/rake gitlab:docs:compile_deprecations`.')
abort
end
end
diff --git a/qa/qa/specs/helpers/context_selector.rb b/qa/qa/specs/helpers/context_selector.rb
index 57665babf68..9ac79ad6196 100644
--- a/qa/qa/specs/helpers/context_selector.rb
+++ b/qa/qa/specs/helpers/context_selector.rb
@@ -45,11 +45,11 @@ module QA
opts[:subdomain] = case option[:subdomain]
when Array
- "(#{option[:subdomain].join("|")})."
+ "(#{option[:subdomain].join("|")})\\."
when Regexp
option[:subdomain]
else
- "(#{option[:subdomain]})."
+ "(#{option[:subdomain]})\\."
end
end
end
diff --git a/qa/spec/specs/helpers/context_selector_spec.rb b/qa/spec/specs/helpers/context_selector_spec.rb
index 0152fee6f5b..5a320cde71f 100644
--- a/qa/spec/specs/helpers/context_selector_spec.rb
+++ b/qa/spec/specs/helpers/context_selector_spec.rb
@@ -186,6 +186,24 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do
end
end
+ context 'staging-ref' do
+ before do
+ QA::Runtime::Scenario.define(:gitlab_address, 'https://staging-ref.gitlab.com/')
+ end
+
+ it 'runs on staging-ref' do
+ group = describe_successfully do
+ it('does not run in staging', only: { subdomain: :staging }) {}
+ it('runs in staging-ref', only: { subdomain: /^staging-ref./ }) {}
+ end
+
+ aggregate_failures do
+ expect(group.examples[0].execution_result.status).to eq(:pending)
+ expect(group.examples[1].execution_result.status).to eq(:passed)
+ end
+ end
+ end
+
context 'production' do
before do
QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.com/')
diff --git a/spec/controllers/groups/settings/integrations_controller_spec.rb b/spec/controllers/groups/settings/integrations_controller_spec.rb
index 9ede6d0b9e9..c070094babd 100644
--- a/spec/controllers/groups/settings/integrations_controller_spec.rb
+++ b/spec/controllers/groups/settings/integrations_controller_spec.rb
@@ -78,7 +78,7 @@ RSpec.describe Groups::Settings::IntegrationsController do
describe '#update' do
include JiraServiceHelper
- let(:integration) { create(:jira_integration, project: nil, group_id: group.id) }
+ let(:integration) { create(:jira_integration, :group, group: group) }
before do
group.add_owner(user)
@@ -108,7 +108,7 @@ RSpec.describe Groups::Settings::IntegrationsController do
end
describe '#reset' do
- let_it_be(:integration) { create(:jira_integration, group: group, project: nil) }
+ let_it_be(:integration) { create(:jira_integration, :group, group: group) }
let_it_be(:inheriting_integration) { create(:jira_integration, inherit_from_id: integration.id) }
subject do
diff --git a/spec/controllers/projects/hooks_controller_spec.rb b/spec/controllers/projects/hooks_controller_spec.rb
index 17baf38ef32..2ab18ccddbf 100644
--- a/spec/controllers/projects/hooks_controller_spec.rb
+++ b/spec/controllers/projects/hooks_controller_spec.rb
@@ -109,7 +109,7 @@ RSpec.describe Projects::HooksController do
describe '#test' do
let(:hook) { create(:project_hook, project: project) }
- context 'when the endpoint receives requests above the limit' do
+ context 'when the endpoint receives requests above the limit', :freeze_time, :clean_gitlab_redis_rate_limiting do
before do
allow(Gitlab::ApplicationRateLimiter).to receive(:rate_limits)
.and_return(project_testing_hook: { threshold: 1, interval: 1.minute })
diff --git a/spec/controllers/projects/services_controller_spec.rb b/spec/controllers/projects/services_controller_spec.rb
index 79784bad67e..29988da6e60 100644
--- a/spec/controllers/projects/services_controller_spec.rb
+++ b/spec/controllers/projects/services_controller_spec.rb
@@ -254,7 +254,7 @@ RSpec.describe Projects::ServicesController do
let_it_be(:project) { create(:project, group: group) }
let_it_be(:jira_integration) { create(:jira_integration, project: project) }
- let(:group_integration) { create(:jira_integration, group: group, project: nil, url: 'http://group.com', password: 'group') }
+ let(:group_integration) { create(:jira_integration, :group, group: group, url: 'http://group.com', password: 'group') }
let(:integration_params) { { inherit_from_id: group_integration.id, url: 'http://custom.com', password: 'custom' } }
it 'ignores submitted params and inherits group settings' do
@@ -269,7 +269,7 @@ RSpec.describe Projects::ServicesController do
context 'when param `inherit_from_id` is set to an unrelated group' do
let_it_be(:group) { create(:group) }
- let(:group_integration) { create(:jira_integration, group: group, project: nil, url: 'http://group.com', password: 'group') }
+ let(:group_integration) { create(:jira_integration, :group, group: group, url: 'http://group.com', password: 'group') }
let(:integration_params) { { inherit_from_id: group_integration.id, url: 'http://custom.com', password: 'custom' } }
it 'ignores the param and saves the submitted settings' do
diff --git a/spec/factories/integrations.rb b/spec/factories/integrations.rb
index 7205a0c40f9..76415f82ed0 100644
--- a/spec/factories/integrations.rb
+++ b/spec/factories/integrations.rb
@@ -222,6 +222,11 @@ FactoryBot.define do
template { true }
end
+ trait :group do
+ group
+ project { nil }
+ end
+
trait :instance do
project { nil }
instance { true }
diff --git a/spec/features/projects/integrations/user_uses_inherited_settings_spec.rb b/spec/features/projects/integrations/user_uses_inherited_settings_spec.rb
index f46cade9d5f..d2c4418f0d6 100644
--- a/spec/features/projects/integrations/user_uses_inherited_settings_spec.rb
+++ b/spec/features/projects/integrations/user_uses_inherited_settings_spec.rb
@@ -84,7 +84,7 @@ RSpec.describe 'User uses inherited settings', :js do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:parent_settings) { { url: 'http://group.com', password: 'group' } }
- let_it_be(:parent_integration) { create(:jira_integration, group: group, project: nil, **parent_settings) }
+ let_it_be(:parent_integration) { create(:jira_integration, :group, group: group, **parent_settings) }
it_behaves_like 'inherited settings'
end
diff --git a/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb b/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb
index 31cf94aef44..bfb6958e327 100644
--- a/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb
+++ b/spec/graphql/types/alert_management/prometheus_integration_type_spec.rb
@@ -50,7 +50,7 @@ RSpec.describe GitlabSchema.types['AlertManagementPrometheusIntegration'] do
describe 'a group integration' do
let_it_be(:group) { create(:group) }
- let_it_be(:integration) { create(:prometheus_integration, project: nil, group: group) }
+ let_it_be(:integration) { create(:prometheus_integration, :group, group: group) }
# Since it is impossible to authorize the parent here, given that the
# project is nil, all fields should be redacted:
diff --git a/spec/lib/gitlab/merge_requests/merge_commit_message_spec.rb b/spec/lib/gitlab/merge_requests/merge_commit_message_spec.rb
index 5b99aa3cd06..884f8df5e56 100644
--- a/spec/lib/gitlab/merge_requests/merge_commit_message_spec.rb
+++ b/spec/lib/gitlab/merge_requests/merge_commit_message_spec.rb
@@ -183,4 +183,37 @@ RSpec.describe Gitlab::MergeRequests::MergeCommitMessage do
end
end
end
+
+ context 'when project has template with CRLF newlines' do
+ let(:merge_commit_template) do
+ "Merge branch '%{source_branch}' into '%{target_branch}'\r\n\r\n%{title}\r\n\r\n%{description}\r\n\r\nSee merge request %{reference}"
+ end
+
+ it 'converts it to LF newlines' do
+ expect(subject.message).to eq <<~MSG.rstrip
+ Merge branch 'feature' into 'master'
+
+ Bugfix
+
+ Merge Request Description
+ Next line
+
+ See merge request #{merge_request.to_reference(full: true)}
+ MSG
+ end
+
+ context 'when description is empty string' do
+ let(:merge_request_description) { '' }
+
+ it 'skips description placeholder and removes new line characters before it' do
+ expect(subject.message).to eq <<~MSG.rstrip
+ Merge branch 'feature' into 'master'
+
+ Bugfix
+
+ See merge request #{merge_request.to_reference(full: true)}
+ MSG
+ end
+ end
+ end
end
diff --git a/spec/models/concerns/has_integrations_spec.rb b/spec/models/concerns/has_integrations_spec.rb
index ea6b0e69209..5a227ed1a57 100644
--- a/spec/models/concerns/has_integrations_spec.rb
+++ b/spec/models/concerns/has_integrations_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe HasIntegrations do
before do
create(:jira_integration, project: project_1, inherit_from_id: instance_integration.id)
create(:jira_integration, project: project_2, inherit_from_id: nil)
- create(:jira_integration, group: create(:group), project: nil, inherit_from_id: nil)
+ create(:jira_integration, :group, group: create(:group), inherit_from_id: nil)
create(:jira_integration, project: project_3, inherit_from_id: nil)
create(:integrations_slack, project: project_4, inherit_from_id: nil)
end
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index ae6513a3bc1..735aa4df2ba 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -582,8 +582,8 @@ RSpec.describe Group do
let(:instance_integration) { build(:jira_integration, :instance) }
before do
- create(:jira_integration, group: group, project: nil)
- create(:integrations_slack, group: another_group, project: nil)
+ create(:jira_integration, :group, group: group)
+ create(:integrations_slack, :group, group: another_group)
end
it 'returns groups without integration' do
diff --git a/spec/models/integration_spec.rb b/spec/models/integration_spec.rb
index 1a83d948fcf..de47fb3839a 100644
--- a/spec/models/integration_spec.rb
+++ b/spec/models/integration_spec.rb
@@ -299,7 +299,7 @@ RSpec.describe Integration do
end
context 'when integration is a group-level integration' do
- let(:group_integration) { create(:jira_integration, group: group, project: nil) }
+ let(:group_integration) { create(:jira_integration, :group, group: group) }
it 'sets inherit_from_id from integration' do
integration = described_class.build_from_integration(group_integration, project_id: project.id)
@@ -458,7 +458,7 @@ RSpec.describe Integration do
end
context 'with an active group-level integration' do
- let!(:group_integration) { create(:prometheus_integration, group: group, project: nil, api_url: 'https://prometheus.group.com/') }
+ let!(:group_integration) { create(:prometheus_integration, :group, group: group, api_url: 'https://prometheus.group.com/') }
it 'creates an integration from the group-level integration' do
described_class.create_from_active_default_integrations(project, :project_id)
@@ -481,7 +481,7 @@ RSpec.describe Integration do
end
context 'with an active subgroup' do
- let!(:subgroup_integration) { create(:prometheus_integration, group: subgroup, project: nil, api_url: 'https://prometheus.subgroup.com/') }
+ let!(:subgroup_integration) { create(:prometheus_integration, :group, group: subgroup, api_url: 'https://prometheus.subgroup.com/') }
let!(:subgroup) { create(:group, parent: group) }
let(:project) { create(:project, group: subgroup) }
@@ -509,7 +509,7 @@ RSpec.describe Integration do
end
context 'having an integration inheriting settings' do
- let!(:subgroup_integration) { create(:prometheus_integration, group: subgroup, project: nil, inherit_from_id: group_integration.id, api_url: 'https://prometheus.subgroup.com/') }
+ let!(:subgroup_integration) { create(:prometheus_integration, :group, group: subgroup, inherit_from_id: group_integration.id, api_url: 'https://prometheus.subgroup.com/') }
it 'creates an integration from the group-level integration' do
described_class.create_from_active_default_integrations(sub_subgroup, :group_id)
@@ -552,11 +552,11 @@ RSpec.describe Integration do
let_it_be(:subgroup2) { create(:group, parent: group) }
let_it_be(:project1) { create(:project, group: subgroup1) }
let_it_be(:project2) { create(:project, group: subgroup2) }
- let_it_be(:group_integration) { create(:prometheus_integration, group: group, project: nil) }
- let_it_be(:subgroup_integration1) { create(:prometheus_integration, group: subgroup1, project: nil, inherit_from_id: group_integration.id) }
- let_it_be(:subgroup_integration2) { create(:prometheus_integration, group: subgroup2, project: nil) }
- let_it_be(:project_integration1) { create(:prometheus_integration, group: nil, project: project1, inherit_from_id: group_integration.id) }
- let_it_be(:project_integration2) { create(:prometheus_integration, group: nil, project: project2, inherit_from_id: subgroup_integration2.id) }
+ let_it_be(:group_integration) { create(:prometheus_integration, :group, group: group) }
+ let_it_be(:subgroup_integration1) { create(:prometheus_integration, :group, group: subgroup1, inherit_from_id: group_integration.id) }
+ let_it_be(:subgroup_integration2) { create(:prometheus_integration, :group, group: subgroup2) }
+ let_it_be(:project_integration1) { create(:prometheus_integration, project: project1, inherit_from_id: group_integration.id) }
+ let_it_be(:project_integration2) { create(:prometheus_integration, project: project2, inherit_from_id: subgroup_integration2.id) }
it 'returns the groups and projects inheriting from integration ancestors', :aggregate_failures do
expect(described_class.inherited_descendants_from_self_or_ancestors_from(group_integration)).to eq([subgroup_integration1, project_integration1])
diff --git a/spec/services/admin/propagate_integration_service_spec.rb b/spec/services/admin/propagate_integration_service_spec.rb
index 151658fe429..b379286ba4f 100644
--- a/spec/services/admin/propagate_integration_service_spec.rb
+++ b/spec/services/admin/propagate_integration_service_spec.rb
@@ -55,7 +55,7 @@ RSpec.describe Admin::PropagateIntegrationService do
end
context 'for a group-level integration' do
- let(:group_integration) { create(:jira_integration, group: group, project: nil) }
+ let(:group_integration) { create(:jira_integration, :group, group: group) }
context 'with a project without integration' do
let(:another_project) { create(:project, group: group) }
@@ -81,7 +81,7 @@ RSpec.describe Admin::PropagateIntegrationService do
context 'with a subgroup with integration' do
let(:subgroup) { create(:group, parent: group) }
- let(:subgroup_integration) { create(:jira_integration, group: subgroup, project: nil, inherit_from_id: group_integration.id) }
+ let(:subgroup_integration) { create(:jira_integration, :group, group: subgroup, inherit_from_id: group_integration.id) }
it 'calls to PropagateIntegrationInheritDescendantWorker' do
expect(PropagateIntegrationInheritDescendantWorker).to receive(:perform_async)
diff --git a/spec/services/bulk_create_integration_service_spec.rb b/spec/services/bulk_create_integration_service_spec.rb
index a536fd415f2..63bdc39857c 100644
--- a/spec/services/bulk_create_integration_service_spec.rb
+++ b/spec/services/bulk_create_integration_service_spec.rb
@@ -74,7 +74,7 @@ RSpec.describe BulkCreateIntegrationService do
context 'with a project association' do
let!(:project) { create(:project, group: group) }
- let(:integration) { create(:jira_integration, group: group, project: nil) }
+ let(:integration) { create(:jira_integration, :group, group: group) }
let(:created_integration) { project.jira_integration }
let(:batch) { Project.where(id: Project.minimum(:id)..Project.maximum(:id)).without_integration(integration).in_namespace(integration.group.self_and_descendants) }
let(:association) { 'project' }
@@ -84,7 +84,7 @@ RSpec.describe BulkCreateIntegrationService do
it_behaves_like 'updates inherit_from_id'
context 'with different foreign key of data_fields' do
- let(:integration) { create(:zentao_integration, group: group, project: nil) }
+ let(:integration) { create(:zentao_integration, :group, group: group) }
let(:created_integration) { project.zentao_integration }
it_behaves_like 'creates integration from batch ids'
@@ -94,7 +94,7 @@ RSpec.describe BulkCreateIntegrationService do
context 'with a group association' do
let!(:subgroup) { create(:group, parent: group) }
- let(:integration) { create(:jira_integration, group: group, project: nil, inherit_from_id: instance_integration.id) }
+ let(:integration) { create(:jira_integration, :group, group: group, inherit_from_id: instance_integration.id) }
let(:created_integration) { Integration.find_by(group: subgroup) }
let(:batch) { Group.where(id: subgroup.id) }
let(:association) { 'group' }
@@ -104,7 +104,7 @@ RSpec.describe BulkCreateIntegrationService do
it_behaves_like 'updates inherit_from_id'
context 'with different foreign key of data_fields' do
- let(:integration) { create(:zentao_integration, group: group, project: nil, inherit_from_id: instance_integration.id) }
+ let(:integration) { create(:zentao_integration, :group, group: group, inherit_from_id: instance_integration.id) }
it_behaves_like 'creates integration from batch ids'
it_behaves_like 'updates inherit_from_id'
diff --git a/spec/services/bulk_update_integration_service_spec.rb b/spec/services/bulk_update_integration_service_spec.rb
index e3a7e4201f7..5e521b98482 100644
--- a/spec/services/bulk_update_integration_service_spec.rb
+++ b/spec/services/bulk_update_integration_service_spec.rb
@@ -16,32 +16,19 @@ RSpec.describe BulkUpdateIntegrationService do
let_it_be(:group) { create(:group) }
let_it_be(:subgroup) { create(:group, parent: group) }
- let_it_be(:group_integration) do
- Integrations::Jira.create!(
- group: group,
- url: 'http://group.jira.com'
- )
- end
-
+ let_it_be(:group_integration) { create(:jira_integration, :group, group: group, url: 'http://group.jira.com') }
+ let_it_be(:excluded_integration) { create(:jira_integration, :group, group: create(:group), url: 'http://another.jira.com', push_events: false) }
let_it_be(:subgroup_integration) do
- Integrations::Jira.create!(
- inherit_from_id: group_integration.id,
+ create(:jira_integration, :group,
group: subgroup,
+ inherit_from_id: group_integration.id,
url: 'http://subgroup.jira.com',
push_events: true
)
end
- let_it_be(:excluded_integration) do
- Integrations::Jira.create!(
- group: create(:group),
- url: 'http://another.jira.com',
- push_events: false
- )
- end
-
let_it_be(:integration) do
- Integrations::Jira.create!(
+ create(:jira_integration,
project: create(:project, group: subgroup),
inherit_from_id: subgroup_integration.id,
url: 'http://project.jira.com',
@@ -92,7 +79,7 @@ RSpec.describe BulkUpdateIntegrationService do
context 'with different foreign key of data_fields' do
let(:integration) { create(:zentao_integration, project: create(:project, group: group)) }
let(:group_integration) do
- Integrations::Zentao.create!(
+ create(:zentao_integration, :group,
group: group,
url: 'https://group.zentao.net',
api_token: 'GROUP_TOKEN',
diff --git a/spec/services/groups/create_service_spec.rb b/spec/services/groups/create_service_spec.rb
index 60e6082c706..7ea08131419 100644
--- a/spec/services/groups/create_service_spec.rb
+++ b/spec/services/groups/create_service_spec.rb
@@ -171,7 +171,7 @@ RSpec.describe Groups::CreateService, '#execute' do
context 'with an active group-level integration' do
let(:service) { described_class.new(user, group_params.merge(parent_id: group.id)) }
- let!(:group_integration) { create(:prometheus_integration, group: group, project: nil, api_url: 'https://prometheus.group.com/') }
+ let!(:group_integration) { create(:prometheus_integration, :group, group: group, api_url: 'https://prometheus.group.com/') }
let(:group) do
create(:group).tap do |group|
group.add_owner(user)
@@ -186,7 +186,7 @@ RSpec.describe Groups::CreateService, '#execute' do
context 'with an active subgroup' do
let(:service) { described_class.new(user, group_params.merge(parent_id: subgroup.id)) }
- let!(:subgroup_integration) { create(:prometheus_integration, group: subgroup, project: nil, api_url: 'https://prometheus.subgroup.com/') }
+ let!(:subgroup_integration) { create(:prometheus_integration, :group, group: subgroup, api_url: 'https://prometheus.subgroup.com/') }
let(:subgroup) do
create(:group, parent: group).tap do |subgroup|
subgroup.add_owner(user)
diff --git a/spec/services/groups/transfer_service_spec.rb b/spec/services/groups/transfer_service_spec.rb
index 6712dccd249..35d46884f4d 100644
--- a/spec/services/groups/transfer_service_spec.rb
+++ b/spec/services/groups/transfer_service_spec.rb
@@ -286,7 +286,7 @@ RSpec.describe Groups::TransferService, :sidekiq_inline do
context 'when the group is allowed to be transferred' do
let_it_be(:new_parent_group, reload: true) { create(:group, :public) }
- let_it_be(:new_parent_group_integration) { create(:integrations_slack, group: new_parent_group, project: nil, webhook: 'http://new-group.slack.com') }
+ let_it_be(:new_parent_group_integration) { create(:integrations_slack, :group, group: new_parent_group, webhook: 'http://new-group.slack.com') }
before do
allow(PropagateIntegrationWorker).to receive(:perform_async)
@@ -323,7 +323,7 @@ RSpec.describe Groups::TransferService, :sidekiq_inline do
context 'with an inherited integration' do
let_it_be(:instance_integration) { create(:integrations_slack, :instance, webhook: 'http://project.slack.com') }
- let_it_be(:group_integration) { create(:integrations_slack, group: group, project: nil, webhook: 'http://group.slack.com', inherit_from_id: instance_integration.id) }
+ let_it_be(:group_integration) { create(:integrations_slack, :group, group: group, webhook: 'http://group.slack.com', inherit_from_id: instance_integration.id) }
it 'replaces inherited integrations', :aggregate_failures do
expect(new_created_integration.webhook).to eq(new_parent_group_integration.webhook)
@@ -333,7 +333,7 @@ RSpec.describe Groups::TransferService, :sidekiq_inline do
end
context 'with a custom integration' do
- let_it_be(:group_integration) { create(:integrations_slack, group: group, project: nil, webhook: 'http://group.slack.com') }
+ let_it_be(:group_integration) { create(:integrations_slack, :group, group: group, webhook: 'http://group.slack.com') }
it 'does not updates the integrations', :aggregate_failures do
expect { transfer_service.execute(new_parent_group) }.not_to change { group_integration.webhook }
diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb
index d903523840c..2aa9be5066f 100644
--- a/spec/services/projects/create_service_spec.rb
+++ b/spec/services/projects/create_service_spec.rb
@@ -666,7 +666,7 @@ RSpec.describe Projects::CreateService, '#execute' do
end
context 'with an active group-level integration' do
- let!(:group_integration) { create(:prometheus_integration, group: group, project: nil, api_url: 'https://prometheus.group.com/') }
+ let!(:group_integration) { create(:prometheus_integration, :group, group: group, api_url: 'https://prometheus.group.com/') }
let!(:group) do
create(:group).tap do |group|
group.add_owner(user)
@@ -687,7 +687,7 @@ RSpec.describe Projects::CreateService, '#execute' do
end
context 'with an active subgroup' do
- let!(:subgroup_integration) { create(:prometheus_integration, group: subgroup, project: nil, api_url: 'https://prometheus.subgroup.com/') }
+ let!(:subgroup_integration) { create(:prometheus_integration, :group, group: subgroup, api_url: 'https://prometheus.subgroup.com/') }
let!(:subgroup) do
create(:group, parent: group).tap do |subgroup|
subgroup.add_owner(user)
diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb
index 2164580a158..c47d44002cc 100644
--- a/spec/services/projects/transfer_service_spec.rb
+++ b/spec/services/projects/transfer_service_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe Projects::TransferService do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
- let_it_be(:group_integration) { create(:integrations_slack, group: group, project: nil, webhook: 'http://group.slack.com') }
+ let_it_be(:group_integration) { create(:integrations_slack, :group, group: group, webhook: 'http://group.slack.com') }
let(:project) { create(:project, :repository, :legacy_storage, namespace: user.namespace) }
diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb
index 6f17d3cb496..ee4621deb2d 100644
--- a/spec/support/helpers/graphql_helpers.rb
+++ b/spec/support/helpers/graphql_helpers.rb
@@ -522,8 +522,7 @@ module GraphqlHelpers
end
end
- # See note at graphql_data about memoization and multiple requests
- def graphql_errors(body = json_response)
+ def graphql_errors(body = fresh_response_data)
case body
when Hash # regular query
body['errors']
diff --git a/spec/support/shared_examples/controllers/create_notes_rate_limit_shared_examples.rb b/spec/support/shared_examples/controllers/create_notes_rate_limit_shared_examples.rb
index 74a98c20383..8affe4ac8f5 100644
--- a/spec/support/shared_examples/controllers/create_notes_rate_limit_shared_examples.rb
+++ b/spec/support/shared_examples/controllers/create_notes_rate_limit_shared_examples.rb
@@ -6,39 +6,41 @@
# - request_full_path
RSpec.shared_examples 'request exceeding rate limit' do
- before do
- stub_application_setting(notes_create_limit: 2)
- 2.times { post :create, params: params }
- end
+ context 'with rate limiter', :freeze_time, :clean_gitlab_redis_rate_limiting do
+ before do
+ stub_application_setting(notes_create_limit: 2)
+ 2.times { post :create, params: params }
+ end
- it 'prevents from creating more notes', :request_store do
- expect { post :create, params: params }
- .to change { Note.count }.by(0)
+ it 'prevents from creating more notes' do
+ expect { post :create, params: params }
+ .to change { Note.count }.by(0)
- expect(response).to have_gitlab_http_status(:too_many_requests)
- expect(response.body).to eq(_('This endpoint has been requested too many times. Try again later.'))
- end
+ expect(response).to have_gitlab_http_status(:too_many_requests)
+ expect(response.body).to eq(_('This endpoint has been requested too many times. Try again later.'))
+ end
- it 'logs the event in auth.log' do
- attributes = {
- message: 'Application_Rate_Limiter_Request',
- env: :notes_create_request_limit,
- remote_ip: '0.0.0.0',
- request_method: 'POST',
- path: request_full_path,
- user_id: user.id,
- username: user.username
- }
+ it 'logs the event in auth.log' do
+ attributes = {
+ message: 'Application_Rate_Limiter_Request',
+ env: :notes_create_request_limit,
+ remote_ip: '0.0.0.0',
+ request_method: 'POST',
+ path: request_full_path,
+ user_id: user.id,
+ username: user.username
+ }
- expect(Gitlab::AuthLogger).to receive(:error).with(attributes).once
- post :create, params: params
- end
+ expect(Gitlab::AuthLogger).to receive(:error).with(attributes).once
+ post :create, params: params
+ end
- it 'allows user in allow-list to create notes, even if the case is different' do
- user.update_attribute(:username, user.username.titleize)
- stub_application_setting(notes_create_limit_allowlist: ["#{user.username.downcase}"])
+ it 'allows user in allow-list to create notes, even if the case is different' do
+ user.update_attribute(:username, user.username.titleize)
+ stub_application_setting(notes_create_limit_allowlist: ["#{user.username.downcase}"])
- post :create, params: params
- expect(response).to have_gitlab_http_status(:found)
+ post :create, params: params
+ expect(response).to have_gitlab_http_status(:found)
+ end
end
end
diff --git a/spec/support/shared_examples/graphql/notes_creation_shared_examples.rb b/spec/support/shared_examples/graphql/notes_creation_shared_examples.rb
index fb598b978f6..56b6dc682eb 100644
--- a/spec/support/shared_examples/graphql/notes_creation_shared_examples.rb
+++ b/spec/support/shared_examples/graphql/notes_creation_shared_examples.rb
@@ -66,20 +66,22 @@ RSpec.shared_examples 'a Note mutation when the given resource id is not for a N
end
RSpec.shared_examples 'a Note mutation when there are rate limit validation errors' do
- before do
- stub_application_setting(notes_create_limit: 3)
- 3.times { post_graphql_mutation(mutation, current_user: current_user) }
- end
-
- it_behaves_like 'a Note mutation that does not create a Note'
- it_behaves_like 'a mutation that returns top-level errors',
- errors: ['This endpoint has been requested too many times. Try again later.']
-
- context 'when the user is in the allowlist' do
+ context 'with rate limiter', :freeze_time, :clean_gitlab_redis_rate_limiting do
before do
- stub_application_setting(notes_create_limit_allowlist: ["#{current_user.username}"])
+ stub_application_setting(notes_create_limit: 3)
+ 3.times { post_graphql_mutation(mutation, current_user: current_user) }
end
- it_behaves_like 'a Note mutation that creates a Note'
+ it_behaves_like 'a Note mutation that does not create a Note'
+ it_behaves_like 'a mutation that returns top-level errors',
+ errors: ['This endpoint has been requested too many times. Try again later.']
+
+ context 'when the user is in the allowlist' do
+ before do
+ stub_application_setting(notes_create_limit_allowlist: ["#{current_user.username}"])
+ end
+
+ it_behaves_like 'a Note mutation that creates a Note'
+ end
end
end
diff --git a/spec/support/shared_examples/requests/api/notes_shared_examples.rb b/spec/support/shared_examples/requests/api/notes_shared_examples.rb
index 40799688144..0434d0beb7e 100644
--- a/spec/support/shared_examples/requests/api/notes_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/notes_shared_examples.rb
@@ -281,7 +281,7 @@ RSpec.shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
end
end
- context 'when request exceeds the rate limit' do
+ context 'when request exceeds the rate limit', :freeze_time, :clean_gitlab_redis_rate_limiting do
before do
stub_application_setting(notes_create_limit: 1)
allow(::Gitlab::ApplicationRateLimiter).to receive(:increment).and_return(2)
diff --git a/spec/workers/propagate_integration_group_worker_spec.rb b/spec/workers/propagate_integration_group_worker_spec.rb
index 9d46534df4f..60442438a1d 100644
--- a/spec/workers/propagate_integration_group_worker_spec.rb
+++ b/spec/workers/propagate_integration_group_worker_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe PropagateIntegrationGroupWorker do
end
context 'with a group integration' do
- let_it_be(:integration) { create(:redmine_integration, group: group, project: nil) }
+ let_it_be(:integration) { create(:redmine_integration, :group, group: group) }
it 'calls to BulkCreateIntegrationService' do
expect(BulkCreateIntegrationService).to receive(:new)
diff --git a/spec/workers/propagate_integration_inherit_descendant_worker_spec.rb b/spec/workers/propagate_integration_inherit_descendant_worker_spec.rb
index 8a231d4104c..c9a7bfaa8b6 100644
--- a/spec/workers/propagate_integration_inherit_descendant_worker_spec.rb
+++ b/spec/workers/propagate_integration_inherit_descendant_worker_spec.rb
@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe PropagateIntegrationInheritDescendantWorker do
let_it_be(:group) { create(:group) }
let_it_be(:subgroup) { create(:group, parent: group) }
- let_it_be(:group_integration) { create(:redmine_integration, group: group, project: nil) }
- let_it_be(:subgroup_integration) { create(:redmine_integration, group: subgroup, project: nil, inherit_from_id: group_integration.id) }
+ let_it_be(:group_integration) { create(:redmine_integration, :group, group: group) }
+ let_it_be(:subgroup_integration) { create(:redmine_integration, :group, group: subgroup, inherit_from_id: group_integration.id) }
it_behaves_like 'an idempotent worker' do
let(:job_args) { [group_integration.id, subgroup_integration.id, subgroup_integration.id] }
diff --git a/spec/workers/propagate_integration_project_worker_spec.rb b/spec/workers/propagate_integration_project_worker_spec.rb
index 312631252cc..c7adf1b826f 100644
--- a/spec/workers/propagate_integration_project_worker_spec.rb
+++ b/spec/workers/propagate_integration_project_worker_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe PropagateIntegrationProjectWorker do
end
context 'with a group integration' do
- let_it_be(:integration) { create(:redmine_integration, group: group, project: nil) }
+ let_it_be(:integration) { create(:redmine_integration, :group, group: group) }
it 'calls to BulkCreateIntegrationService' do
expect(BulkCreateIntegrationService).to receive(:new)