diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/lib/gitlab/markdown_cache/redis/extension_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/lib/gitlab/markdown_cache/redis/extension_spec.rb')
-rw-r--r-- | spec/lib/gitlab/markdown_cache/redis/extension_spec.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/spec/lib/gitlab/markdown_cache/redis/extension_spec.rb b/spec/lib/gitlab/markdown_cache/redis/extension_spec.rb index b6a781de426..3dcb9f160ba 100644 --- a/spec/lib/gitlab/markdown_cache/redis/extension_spec.rb +++ b/spec/lib/gitlab/markdown_cache/redis/extension_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -describe Gitlab::MarkdownCache::Redis::Extension, :clean_gitlab_redis_cache do +RSpec.describe Gitlab::MarkdownCache::Redis::Extension, :clean_gitlab_redis_cache do let(:klass) do Class.new do include CacheMarkdownField @@ -49,6 +49,31 @@ describe Gitlab::MarkdownCache::Redis::Extension, :clean_gitlab_redis_cache do expect(thing.cached_markdown_version).to eq(cache_version) end + describe '.preload_markdown_cache!' do + before do + Gitlab::Redis::Cache.with do |r| + r.mapped_hmset(expected_cache_key, + title_html: 'hello', + description_html: 'world', + cached_markdown_version: cache_version) + end + end + + it 'does not preload the markdown twice' do + expect(Gitlab::MarkdownCache::Redis::Store).to receive(:bulk_read).and_call_original + expect(Gitlab::Redis::Cache).to receive(:with).twice.and_call_original + + klass.preload_markdown_cache!([thing]) + + aggregate_failures do + expect(Gitlab::Redis::Cache).not_to receive(:with) + expect(thing.title_html).to eq('hello') + expect(thing.description_html).to eq('world') + expect(thing.cached_markdown_version).to eq(cache_version) + end + end + end + describe "#refresh_markdown_cache!" do it "stores the value in redis" do expected_results = { "title_html" => "`Hello`", |