Commit 7fe9058c authored by Kerri Miller's avatar Kerri Miller

Scope tests against DeprecatedHighlightCache

parent baedc099
......@@ -29,6 +29,11 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
let(:diffable) { merge_request.merge_request_diff }
end
context 'using Gitlab::Diff::DeprecatedHighlightCache' do
before do
stub_feature_flags(redis_diff_caching: false)
end
it 'uses a different cache key if diff line keys change' do
mr_diff = described_class.new(merge_request.merge_request_diff, diff_options: nil)
key = mr_diff.cache_key
......@@ -37,6 +42,7 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
expect(mr_diff.cache_key).not_to eq(key)
end
end
it_behaves_like 'diff statistics' do
let(:collection_default_args) do
......
......@@ -33,6 +33,11 @@ describe MergeRequests::ReloadDiffsService, :use_clean_rails_memory_store_cachin
end
context 'cache clearing' do
context 'using Gitlab::Diff::DeprecatedHighlightCache' do
before do
stub_feature_flags(redis_diff_caching: false)
end
it 'clears the cache for older diffs on the merge request' do
old_diff = merge_request.merge_request_diff
old_cache_key = old_diff.diffs_collection.cache_key
......@@ -41,6 +46,22 @@ describe MergeRequests::ReloadDiffsService, :use_clean_rails_memory_store_cachin
subject.execute
end
end
context 'using Gitlab::Diff::HighlightCache' do
before do
stub_feature_flags(redis_diff_caching: true)
end
it 'clears the cache for older diffs on the merge request' do
old_diff = merge_request.merge_request_diff
old_cache_key = old_diff.diffs_collection.cache_key
expect_any_instance_of(Redis).to receive(:del).with(old_cache_key).and_call_original
subject.execute
end
end
it 'avoids N+1 queries', :request_store do
current_user
......
......@@ -87,11 +87,29 @@ describe Notes::CreateService do
.to receive(:unfolded_diff?) { true }
end
context 'using Gitlab::Diff::DeprecatedHighlightCache' do
before do
stub_feature_flags(redis_diff_caching: false)
end
it 'clears noteable diff cache when it was unfolded for the note position' do
expect_any_instance_of(Gitlab::Diff::DeprecatedHighlightCache).to receive(:clear)
described_class.new(project_with_repo, user, new_opts).execute
end
end
context 'using Gitlab::Diff::HighlightCache' do
before do
stub_feature_flags(redis_diff_caching: true)
end
it 'clears noteable diff cache when it was unfolded for the note position' do
expect_any_instance_of(Gitlab::Diff::HighlightCache).to receive(:clear)
described_class.new(project_with_repo, user, new_opts).execute
end
end
it 'does not clear cache when note is not the first of the discussion' do
prev_note =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment