Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-03 18:10:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-03 18:10:53 +0300
commit7fcda12793acc54ba8de037f50cc3696dbd0f002 (patch)
tree044fbc2b142e6c82ee6b2a5df4b37d000c0e2d1f /spec/services
parentb5820a6bcd083c878a085aa288757e8dc2d35fec (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/application_settings/update_service_spec.rb1
-rw-r--r--spec/services/merge_requests/update_service_spec.rb17
-rw-r--r--spec/services/projects/destroy_service_spec.rb29
3 files changed, 45 insertions, 2 deletions
diff --git a/spec/services/application_settings/update_service_spec.rb b/spec/services/application_settings/update_service_spec.rb
index 1352a595ba4..258b3d25aee 100644
--- a/spec/services/application_settings/update_service_spec.rb
+++ b/spec/services/application_settings/update_service_spec.rb
@@ -123,6 +123,7 @@ RSpec.describe ApplicationSettings::UpdateService do
it_behaves_like 'invalidates markdown cache', { asset_proxy_url: 'http://test.com' }
it_behaves_like 'invalidates markdown cache', { asset_proxy_secret_key: 'another secret' }
it_behaves_like 'invalidates markdown cache', { asset_proxy_allowlist: ['domain.com'] }
+ it_behaves_like 'invalidates markdown cache', { asset_proxy_whitelist: ['domain.com'] }
context 'when also setting the local_markdown_version' do
let(:params) { { asset_proxy_enabled: true, local_markdown_version: 12 } }
diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb
index e9ec3bccda3..30d94a2e948 100644
--- a/spec/services/merge_requests/update_service_spec.rb
+++ b/spec/services/merge_requests/update_service_spec.rb
@@ -169,6 +169,23 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
end
end
end
+
+ it 'tracks time estimate and spend time changes' do
+ expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
+ .to receive(:track_time_estimate_changed_action).once.with(user: user)
+
+ expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
+ .to receive(:track_time_spent_changed_action).once.with(user: user)
+
+ opts[:time_estimate] = 86400
+ opts[:spend_time] = {
+ duration: 3600,
+ user_id: user.id,
+ spent_at: Date.parse('2021-02-24')
+ }
+
+ MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
+ end
end
context 'updating milestone' do
diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb
index 75d1c98923a..6fa3d6efbb5 100644
--- a/spec/services/projects/destroy_service_spec.rb
+++ b/spec/services/projects/destroy_service_spec.rb
@@ -31,9 +31,34 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do
end
shared_examples 'deleting the project with pipeline and build' do
- context 'with pipeline and build', :sidekiq_inline do # which has optimistic locking
+ context 'with pipeline and build related records', :sidekiq_inline do # which has optimistic locking
let!(:pipeline) { create(:ci_pipeline, project: project) }
- let!(:build) { create(:ci_build, :artifacts, pipeline: pipeline) }
+ let!(:build) { create(:ci_build, :artifacts, :with_runner_session, pipeline: pipeline) }
+ let!(:trace_chunks) { create(:ci_build_trace_chunk, build: build) }
+ let!(:job_variables) { create(:ci_job_variable, job: build) }
+ let!(:report_result) { create(:ci_build_report_result, build: build) }
+ let!(:pending_state) { create(:ci_build_pending_state, build: build) }
+
+ it 'deletes build related records' do
+ expect { destroy_project(project, user, {}) }.to change { Ci::Build.count }.by(-1)
+ .and change { Ci::BuildTraceChunk.count }.by(-1)
+ .and change { Ci::JobArtifact.count }.by(-2)
+ .and change { Ci::JobVariable.count }.by(-1)
+ .and change { Ci::BuildPendingState.count }.by(-1)
+ .and change { Ci::BuildReportResult.count }.by(-1)
+ .and change { Ci::BuildRunnerSession.count }.by(-1)
+ end
+
+ it 'avoids N+1 queries', skip: 'skipped until fixed in https://gitlab.com/gitlab-org/gitlab/-/issues/24644' do
+ recorder = ActiveRecord::QueryRecorder.new { destroy_project(project, user, {}) }
+
+ project = create(:project, :repository, namespace: user.namespace)
+ pipeline = create(:ci_pipeline, project: project)
+ builds = create_list(:ci_build, 3, :artifacts, pipeline: pipeline)
+ create_list(:ci_build_trace_chunk, 3, build: builds[0])
+
+ expect { destroy_project(project, project.owner, {}) }.not_to exceed_query_limit(recorder)
+ end
it_behaves_like 'deleting the project'
end