2eecfd8f9d
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`.
22 lines
788 B
Ruby
22 lines
788 B
Ruby
require 'spec_helper'
|
|
|
|
describe Banzai::CommitRenderer do
|
|
describe '.render', :clean_gitlab_redis_cache do
|
|
it 'renders a commit description and title' do
|
|
user = build(:user)
|
|
project = create(:project, :repository)
|
|
|
|
expect(Banzai::ObjectRenderer)
|
|
.to receive(:new)
|
|
.with(user: user, default_project: project)
|
|
.and_call_original
|
|
|
|
described_class::ATTRIBUTES.each do |attr|
|
|
expect_any_instance_of(Banzai::ObjectRenderer).to receive(:render).with([project.commit], attr).once.and_call_original
|
|
expect(Banzai::Renderer).to receive(:cacheless_render_field).with(project.commit, attr, { skip_project_check: false }).and_call_original
|
|
end
|
|
|
|
described_class.render([project.commit], project, user)
|
|
end
|
|
end
|
|
end
|