summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-09 00:06:09 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-09 00:06:09 +0000
commit5c62758e66b6cb9df3f6415dc8da5d65c4d3b5fd (patch)
treed53c3260f2fac75d972b800af0ec72cef02e3d56 /spec
parent91683dcaa048bde2216c88fde4f49c7ec0e9e373 (diff)
downloadgitlab-ce-5c62758e66b6cb9df3f6415dc8da5d65c4d3b5fd.tar.gz
Add latest changes from gitlab-org/gitlab@15-10-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/models/merge_request_spec.rb9
-rw-r--r--spec/models/repository_spec.rb12
-rw-r--r--spec/services/draft_notes/publish_service_spec.rb7
-rw-r--r--spec/services/merge_requests/reload_diffs_service_spec.rb5
4 files changed, 28 insertions, 5 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index b82b16fdec3..b2887b7e313 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -4261,10 +4261,14 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev
subject { create(:merge_request, source_project: project) }
- it 'fetches the ref correctly' do
+ it 'fetches the ref and expires the ancestor cache' do
expect { subject.target_project.repository.delete_refs(subject.ref_path) }.not_to raise_error
+ expect(project.repository).to receive(:expire_ancestor_cache).with(subject.target_branch_sha, subject.diff_head_sha).and_call_original
+ expect(subject).to receive(:expire_ancestor_cache).and_call_original
+
subject.fetch_ref!
+
expect(subject.target_project.repository.ref_exists?(subject.ref_path)).to be_truthy
end
end
@@ -4275,7 +4279,8 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev
# We use build instead of create to test that an IID is allocated
subject { build(:merge_request, source_project: project) }
- it 'fetches the ref correctly' do
+ it 'fetches the ref and expires the ancestor cache' do
+ expect(subject).to receive(:expire_ancestor_cache).and_call_original
expect(subject.iid).to be_nil
expect { subject.eager_fetch_ref! }.to change { subject.iid.to_i }.by(1)
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index f970e818db9..337bcfbca9d 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -3123,6 +3123,18 @@ RSpec.describe Repository, feature_category: :source_code_management do
2.times { repository.ancestor?(commit.id, ancestor.id) }
end
+ it 'calls out to Gitaly again after expiration' do
+ expect(repository.raw_repository).to receive(:ancestor?).once
+
+ repository.ancestor?(commit.id, ancestor.id)
+
+ repository.expire_ancestor_cache(commit.id, ancestor.id)
+
+ expect(repository.raw_repository).to receive(:ancestor?).once
+
+ 2.times { repository.ancestor?(commit.id, ancestor.id) }
+ end
+
it 'returns the value from the request store' do
repository.__send__(:request_store_cache).write(cache_key, "it's apparent")
diff --git a/spec/services/draft_notes/publish_service_spec.rb b/spec/services/draft_notes/publish_service_spec.rb
index a4b1d8742d0..dab06637c1a 100644
--- a/spec/services/draft_notes/publish_service_spec.rb
+++ b/spec/services/draft_notes/publish_service_spec.rb
@@ -172,7 +172,12 @@ RSpec.describe DraftNotes::PublishService, feature_category: :code_review_workfl
end
end
- it 'does not requests a lot from Gitaly', :request_store do
+ it 'does not request a lot from Gitaly', :request_store, :clean_gitlab_redis_cache do
+ merge_request
+ position
+
+ Gitlab::GitalyClient.reset_counts
+
# NOTE: This should be reduced as we work on reducing Gitaly calls.
# Gitaly requests shouldn't go above this threshold as much as possible
# as it may add more to the Gitaly N+1 issue we are experiencing.
diff --git a/spec/services/merge_requests/reload_diffs_service_spec.rb b/spec/services/merge_requests/reload_diffs_service_spec.rb
index 4dd05f75a3e..f079e3983d7 100644
--- a/spec/services/merge_requests/reload_diffs_service_spec.rb
+++ b/spec/services/merge_requests/reload_diffs_service_spec.rb
@@ -35,8 +35,9 @@ feature_category: :code_review_workflow do
context 'cache clearing' do
it 'clears the cache for older diffs on the merge request' do
- expect_any_instance_of(Redis).to receive(:del).once.and_call_original
- expect(Rails.cache).to receive(:delete).once.and_call_original
+ expect_next_instance_of(Gitlab::Diff::FileCollection::MergeRequestDiff) do |instance|
+ expect(instance).to receive(:clear_cache).and_call_original
+ end
subject.execute
end