diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-16 15:07:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-16 15:07:43 +0300 |
commit | d10a462fedbd7794a83abdba9b4526600f71de5b (patch) | |
tree | 4dbd21cb89013d9e07b05bac5101cd13585a8be5 /spec/lib/gitlab/diff | |
parent | 13867d66e92c2fd8962a126db4fbdc32891343c9 (diff) |
Add latest changes from gitlab-org/gitlab@masterogolowinski-master-patch-80898
Diffstat (limited to 'spec/lib/gitlab/diff')
-rw-r--r-- | spec/lib/gitlab/diff/highlight_cache_spec.rb | 25 | ||||
-rw-r--r-- | spec/lib/gitlab/diff/highlight_spec.rb | 4 |
2 files changed, 24 insertions, 5 deletions
diff --git a/spec/lib/gitlab/diff/highlight_cache_spec.rb b/spec/lib/gitlab/diff/highlight_cache_spec.rb index 7daf086843b..c73ec84e332 100644 --- a/spec/lib/gitlab/diff/highlight_cache_spec.rb +++ b/spec/lib/gitlab/diff/highlight_cache_spec.rb @@ -79,10 +79,8 @@ describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do end end - describe '#write_if_empty' do + shared_examples 'caches missing entries' do it 'filters the key/value list of entries to be caches for each invocation' do - paths = merge_request.diffs.diff_files.select(&:text?).map(&:file_path) - expect(cache).to receive(:write_to_redis_hash) .with(hash_including(*paths)) .once @@ -96,6 +94,12 @@ describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do cache.write_if_empty end + end + + describe '#write_if_empty' do + it_behaves_like 'caches missing entries' do + let(:paths) { merge_request.diffs.raw_diff_files.select(&:text?).map(&:file_path) } + end context 'different diff_collections for the same diffable' do before do @@ -109,6 +113,21 @@ describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do .to change { Gitlab::Redis::Cache.with { |r| r.hgetall(cache_key) } } end end + + context 'when cache initialized with MergeRequestDiffBatch' do + let(:merge_request_diff_batch) do + Gitlab::Diff::FileCollection::MergeRequestDiffBatch.new( + merge_request.merge_request_diff, + 1, + 10, + diff_options: nil) + end + + it_behaves_like 'caches missing entries' do + let(:cache) { described_class.new(merge_request_diff_batch) } + let(:paths) { merge_request_diff_batch.raw_diff_files.select(&:text?).map(&:file_path) } + end + end end describe '#write_to_redis_hash' do diff --git a/spec/lib/gitlab/diff/highlight_spec.rb b/spec/lib/gitlab/diff/highlight_spec.rb index 1a14f6d4f67..ff4ec75358e 100644 --- a/spec/lib/gitlab/diff/highlight_spec.rb +++ b/spec/lib/gitlab/diff/highlight_spec.rb @@ -105,7 +105,7 @@ describe Gitlab::Diff::Highlight do end it 'keeps the original rich line' do - allow(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception) + allow(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception) code = %q{+ raise RuntimeError, "System commands must be given as an array of strings"} @@ -114,7 +114,7 @@ describe Gitlab::Diff::Highlight do end it 'reports to Sentry if configured' do - expect(Gitlab::Sentry).to receive(:track_and_raise_for_dev_exception).and_call_original + expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception).and_call_original expect { subject }. to raise_exception(RangeError) end |