summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorPatrick Bajao <ebajao@gitlab.com>2019-06-04 20:59:48 -0800
committerPatrick Bajao <ebajao@gitlab.com>2019-06-05 13:19:59 +0800
commit2eecfd8f9d111c6518930b818a16daea8263b37f (patch)
tree12234d26e6e5a950ad69741e761ef7d3d079fdd1 /spec/helpers
parentb560ce1e666733f12c65e8b9f659c89256c1775b (diff)
downloadgitlab-ce-2eecfd8f9d111c6518930b818a16daea8263b37f.tar.gz
Use Redis for CacheMarkDownField on non AR models
This allows using `CacheMarkdownField` for models that are not backed by ActiveRecord. When the including class inherits `ActiveRecord::Base` we include `Gitlab::MarkdownCache::ActiveRecord::Extension`. This will cause the markdown fields to be rendered and the generated HTML stored in a `<field>_html` attribute on the record. We also store the version used for generating the markdown. All other classes that include this model will include the `Gitlab::MarkdownCache::Redis::Extension`. This add the `<field>_html` attributes to that model and will generate the html in them. The generated HTML will be cached in redis under the key `markdown_cache:<class>:<id>`. The class this included in must therefore respond to `id`.
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/markup_helper_spec.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb
index c3956ba08fd..597c8f836a9 100644
--- a/spec/helpers/markup_helper_spec.rb
+++ b/spec/helpers/markup_helper_spec.rb
@@ -78,7 +78,8 @@ describe MarkupHelper do
let(:link) { '/commits/0a1b2c3d' }
let(:issues) { create_list(:issue, 2, project: project) }
- it 'handles references nested in links with all the text' do
+ # Clean the cache to make sure the title is re-rendered from the stubbed one
+ it 'handles references nested in links with all the text', :clean_gitlab_redis_cache do
allow(commit).to receive(:title).and_return("This should finally fix #{issues[0].to_reference} and #{issues[1].to_reference} for real")
actual = helper.link_to_markdown_field(commit, :title, link)