diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 06:08:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 06:08:50 +0300 |
commit | 1d388ed855838a2d50588c131f9f23815f148344 (patch) | |
tree | d9278b42419b6a91c90aa4940c69684077d34273 /spec/lib/gitlab/diff | |
parent | c36e59283ebcfd75281a9dda227ed060eeb5fbe7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/diff')
-rw-r--r-- | spec/lib/gitlab/diff/deprecated_highlight_cache_spec.rb | 70 | ||||
-rw-r--r-- | spec/lib/gitlab/diff/highlight_cache_spec.rb | 10 |
2 files changed, 0 insertions, 80 deletions
diff --git a/spec/lib/gitlab/diff/deprecated_highlight_cache_spec.rb b/spec/lib/gitlab/diff/deprecated_highlight_cache_spec.rb deleted file mode 100644 index 7e46632ea77..00000000000 --- a/spec/lib/gitlab/diff/deprecated_highlight_cache_spec.rb +++ /dev/null @@ -1,70 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe Gitlab::Diff::DeprecatedHighlightCache do - let(:merge_request) { create(:merge_request_with_diffs) } - - subject(:cache) { described_class.new(merge_request.diffs, backend: backend) } - - describe '#decorate' do - let(:backend) { double('backend').as_null_object } - - # Manually creates a Diff::File object to avoid triggering the cache on - # the FileCollection::MergeRequestDiff - let(:diff_file) do - diffs = merge_request.diffs - raw_diff = diffs.diffable.raw_diffs(diffs.diff_options.merge(paths: ['CHANGELOG'])).first - Gitlab::Diff::File.new(raw_diff, - repository: diffs.project.repository, - diff_refs: diffs.diff_refs, - fallback_diff_refs: diffs.fallback_diff_refs) - end - - it 'does not calculate highlighting when reading from cache' do - cache.write_if_empty - cache.decorate(diff_file) - - expect_any_instance_of(Gitlab::Diff::Highlight).not_to receive(:highlight) - - diff_file.highlighted_diff_lines - end - - it 'assigns highlighted diff lines to the DiffFile' do - cache.write_if_empty - cache.decorate(diff_file) - - expect(diff_file.highlighted_diff_lines.size).to be > 5 - end - - it 'submits a single reading from the cache' do - cache.decorate(diff_file) - cache.decorate(diff_file) - - expect(backend).to have_received(:read).with(cache.key).once - end - end - - describe '#write_if_empty' do - let(:backend) { double('backend', read: {}).as_null_object } - - it 'submits a single writing to the cache' do - cache.write_if_empty - cache.write_if_empty - - expect(backend).to have_received(:write).with(cache.key, - hash_including('CHANGELOG-false-false-false'), - expires_in: 1.week).once - end - end - - describe '#clear' do - let(:backend) { double('backend').as_null_object } - - it 'clears cache' do - cache.clear - - expect(backend).to have_received(:delete).with(cache.key) - end - end -end diff --git a/spec/lib/gitlab/diff/highlight_cache_spec.rb b/spec/lib/gitlab/diff/highlight_cache_spec.rb index c73ec84e332..bff51709c40 100644 --- a/spec/lib/gitlab/diff/highlight_cache_spec.rb +++ b/spec/lib/gitlab/diff/highlight_cache_spec.rb @@ -135,16 +135,6 @@ describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do expect { cache.send(:write_to_redis_hash, diff_hash) } .to change { Gitlab::Redis::Cache.with { |r| r.hgetall(cache_key) } } end - - # Note that this spec and the code it confirms can be removed when - # :hset_redis_diff_caching is fully launched. - # - it 'attempts to clear deprecated cache entries' do - expect_any_instance_of(Gitlab::Diff::DeprecatedHighlightCache) - .to receive(:clear).and_call_original - - cache.send(:write_to_redis_hash, diff_hash) - end end describe '#clear' do |