Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ee30fe0b
Commit
ee30fe0b
authored
Jun 08, 2018
by
Lukas Eipert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teach `render_ce` to also search for full views
parent
50f409de
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
ee/app/helpers/ee/application_helper.rb
ee/app/helpers/ee/application_helper.rb
+10
-3
ee/app/views/projects/merge_requests/show.html.haml
ee/app/views/projects/merge_requests/show.html.haml
+1
-1
ee/spec/helpers/application_helper_spec.rb
ee/spec/helpers/application_helper_spec.rb
+16
-2
No files found.
ee/app/helpers/ee/application_helper.rb
View file @
ee30fe0b
...
@@ -11,11 +11,18 @@ module EE
...
@@ -11,11 +11,18 @@ module EE
end
end
def
render_ce
(
partial
,
locals
=
{})
def
render_ce
(
partial
,
locals
=
{})
render
template:
find_ce_
partial
(
partial
),
locals:
locals
render
template:
find_ce_
template
(
partial
),
locals:
locals
end
end
def
find_ce_partial
(
partial
)
# Tries to find a matching partial first, if there is none, we try to find a matching view
ce_lookup_context
.
find
(
partial
,
[],
true
)
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
end
def
ce_lookup_context
def
ce_lookup_context
...
...
ee/app/views/projects/merge_requests/show.html.haml
View file @
ee30fe0b
=
render
:file
=>
"/app/views/
projects/merge_requests/show"
=
render
_ce
"
projects/merge_requests/show"
-# haml-lint:disable InlineJavaScript
-# haml-lint:disable InlineJavaScript
:javascript
:javascript
...
...
ee/spec/helpers/application_helper_spec.rb
View file @
ee30fe0b
...
@@ -15,6 +15,7 @@ describe ApplicationHelper do
...
@@ -15,6 +15,7 @@ describe ApplicationHelper do
context
'when both CE and EE has partials with the same name'
do
context
'when both CE and EE has partials with the same name'
do
let
(
:partial
)
{
'shared/issuable/form/default_templates'
}
let
(
:partial
)
{
'shared/issuable/form/default_templates'
}
let
(
:view
)
{
'projects/merge_requests/show'
}
let
(
:project
)
{
build_stubbed
(
:project
)
}
let
(
:project
)
{
build_stubbed
(
:project
)
}
describe
'#render_ce'
do
describe
'#render_ce'
do
...
@@ -31,13 +32,16 @@ describe ApplicationHelper do
...
@@ -31,13 +32,16 @@ describe ApplicationHelper do
end
end
end
end
describe
'#find_ce_
partial
'
do
describe
'#find_ce_
template
'
do
let
(
:expected_partial_path
)
do
let
(
:expected_partial_path
)
do
"app/views/
#{
File
.
dirname
(
partial
)
}
/_
#{
File
.
basename
(
partial
)
}
.html.haml"
"app/views/
#{
File
.
dirname
(
partial
)
}
/_
#{
File
.
basename
(
partial
)
}
.html.haml"
end
end
let
(
:expected_view_path
)
do
"app/views/
#{
File
.
dirname
(
view
)
}
/
#{
File
.
basename
(
view
)
}
.html.haml"
end
it
'finds the CE partial'
do
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
)
expect
(
ce_partial
.
inspect
).
to
eq
(
expected_partial_path
)
...
@@ -45,6 +49,16 @@ describe ApplicationHelper do
...
@@ -45,6 +49,16 @@ describe ApplicationHelper do
ee_partial
=
helper
.
lookup_context
.
find
(
partial
,
[],
true
)
ee_partial
=
helper
.
lookup_context
.
find
(
partial
,
[],
true
)
expect
(
ee_partial
.
inspect
).
to
eq
(
"ee/
#{
expected_partial_path
}
"
)
expect
(
ee_partial
.
inspect
).
to
eq
(
"ee/
#{
expected_partial_path
}
"
)
end
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
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment