Fix ProjectCacheWorker for plain READMEs

The ProjectCacheWorker refreshes cache periodically, but it runs outside Rails
context. So include the ActionView helpers so the `content_tag` method is
available.
This commit is contained in:
Toon Claes 2017-05-18 21:06:38 +02:00
parent e4eec19156
commit abc82a2508
2 changed files with 15 additions and 0 deletions

View file

@ -1,6 +1,9 @@
require 'nokogiri'
module MarkupHelper
include ActionView::Helpers::TagHelper
include ActionView::Context
def plain?(filename)
Gitlab::MarkupHelper.plain?(filename)
end

View file

@ -45,6 +45,18 @@ describe ProjectCacheWorker do
worker.perform(project.id, %w(readme))
end
context 'with plain readme' do
it 'refreshes the method caches' do
allow(MarkupHelper).to receive(:gitlab_markdown?).and_return(false)
allow(MarkupHelper).to receive(:plain?).and_return(true)
expect_any_instance_of(Repository).to receive(:refresh_method_caches).
with(%i(readme)).
and_call_original
worker.perform(project.id, %w(readme))
end
end
end
end