Commit ee30fe0b authored by Lukas Eipert's avatar Lukas Eipert

teach `render_ce` to also search for full views

parent 50f409de
......@@ -11,11 +11,18 @@ module EE
end
def render_ce(partial, locals = {})
render template: find_ce_partial(partial), locals: locals
render template: find_ce_template(partial), locals: locals
end
def find_ce_partial(partial)
ce_lookup_context.find(partial, [], true)
# Tries to find a matching partial first, if there is none, we try to find a matching view
def find_ce_template(name)
prefixes = [] # So don't create extra [] garbage
if ce_lookup_context.exists?(name, prefixes, true)
ce_lookup_context.find(name, prefixes, true)
else
ce_lookup_context.find(name, prefixes, false)
end
end
def ce_lookup_context
......
= render :file => "/app/views/projects/merge_requests/show"
= render_ce "projects/merge_requests/show"
-# haml-lint:disable InlineJavaScript
:javascript
......
......@@ -15,6 +15,7 @@ describe ApplicationHelper do
context 'when both CE and EE has partials with the same name' do
let(:partial) { 'shared/issuable/form/default_templates' }
let(:view) { 'projects/merge_requests/show' }
let(:project) { build_stubbed(:project) }
describe '#render_ce' do
......@@ -31,13 +32,16 @@ describe ApplicationHelper do
end
end
describe '#find_ce_partial' do
describe '#find_ce_template' do
let(:expected_partial_path) do
"app/views/#{File.dirname(partial)}/_#{File.basename(partial)}.html.haml"
end
let(:expected_view_path) do
"app/views/#{File.dirname(view)}/#{File.basename(view)}.html.haml"
end
it 'finds the CE partial' do
ce_partial = helper.find_ce_partial(partial)
ce_partial = helper.find_ce_template(partial)
expect(ce_partial.inspect).to eq(expected_partial_path)
......@@ -45,6 +49,16 @@ describe ApplicationHelper do
ee_partial = helper.lookup_context.find(partial, [], true)
expect(ee_partial.inspect).to eq("ee/#{expected_partial_path}")
end
it 'finds the CE view' do
ce_view = helper.find_ce_template(view)
expect(ce_view.inspect).to eq(expected_view_path)
# And it could still find the EE view
ee_view = helper.lookup_context.find(view, [], false)
expect(ee_view.inspect).to eq("ee/#{expected_view_path}")
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment