summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-08 23:30:10 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-08 23:30:10 +0000
commit0cb58c941627c8237e65a67e83aa9ff8b59109ae (patch)
tree48c538a7949ece08c9d40f0add511e178b99478c /spec/models
parent420b51f691eacc2ccc1aae931988cbe45cdc4759 (diff)
downloadgitlab-ce-0cb58c941627c8237e65a67e83aa9ff8b59109ae.tar.gz
Add latest changes from gitlab-org/gitlab@15-11-stable-ee
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/merge_request_spec.rb9
-rw-r--r--spec/models/repository_spec.rb12
2 files changed, 19 insertions, 2 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index f3aa174a964..9460aa5d3c7 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 72011693e20..ea237768333 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -3132,6 +3132,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")