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
c1847dd3
Commit
c1847dd3
authored
May 30, 2018
by
Lin Jen-Shin
Committed by
Rémy Coutable
May 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add render_ce to render CE partial in EE partial
parent
63749fae
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
7 deletions
+68
-7
app/views/shared/issuable/form/_default_templates.html.haml
app/views/shared/issuable/form/_default_templates.html.haml
+4
-0
app/views/shared/issuable/form/_title.html.haml
app/views/shared/issuable/form/_title.html.haml
+1
-7
ee/app/helpers/ee/application_helper.rb
ee/app/helpers/ee/application_helper.rb
+24
-0
ee/app/views/shared/issuable/form/_default_templates.html.haml
...p/views/shared/issuable/form/_default_templates.html.haml
+4
-0
ee/spec/helpers/application_helper_spec.rb
ee/spec/helpers/application_helper_spec.rb
+35
-0
No files found.
app/views/shared/issuable/form/_default_templates.html.haml
0 → 100644
View file @
c1847dd3
%p
.form-text.text-muted
Add
=
link_to
'description templates'
,
help_page_path
(
'user/project/description_templates'
),
tabindex:
-
1
to help your contributors communicate effectively!
app/views/shared/issuable/form/_title.html.haml
View file @
c1847dd3
...
...
@@ -30,10 +30,4 @@
merge request from being merged before it's ready.
-
if
no_issuable_templates
&&
can?
(
current_user
,
:push_code
,
issuable
.
project
)
-
if
@project
.
feature_available?
(
:issuable_default_templates
)
%p
.form-text.text-muted
Add
=
link_to
'description templates'
,
help_page_path
(
'user/project/description_templates'
),
tabindex:
-
1
to help your contributors communicate effectively!
-
elsif
show_promotions?
=
render
'shared/promotions/promote_issue_templates'
=
render
'shared/issuable/form/default_templates'
ee/app/helpers/ee/application_helper.rb
View file @
c1847dd3
...
...
@@ -10,6 +10,30 @@ module EE
{
primary_node:
link_to
(
'primary node'
,
::
Gitlab
::
Geo
.
primary_node
.
url
)
}).
html_safe
end
def
render_ce
(
partial
)
render
template:
find_ce_partial
(
partial
)
end
def
find_ce_partial
(
partial
)
ce_lookup_context
.
find
(
partial
,
[],
true
)
end
def
ce_lookup_context
@ce_lookup_context
||=
begin
context
=
lookup_context
.
dup
# This could duplicate the paths we're going to modify
context
.
view_paths
=
lookup_context
.
view_paths
.
paths
# Discard lookup path ee/ for the new paths
context
.
view_paths
.
paths
.
delete_if
do
|
resolver
|
resolver
.
to_path
.
start_with?
(
"
#{
Rails
.
root
}
/ee"
)
end
context
end
end
def
page_class
class_names
=
super
class_names
+=
system_message_class
...
...
ee/app/views/shared/issuable/form/_default_templates.html.haml
0 → 100644
View file @
c1847dd3
-
if
@project
.
feature_available?
(
:issuable_default_templates
)
=
render_ce
'shared/issuable/form/default_templates'
-
elsif
show_promotions?
=
render
'shared/promotions/promote_issue_templates'
ee/spec/helpers/application_helper_spec.rb
View file @
c1847dd3
...
...
@@ -12,4 +12,39 @@ describe ApplicationHelper do
end
end
end
context
'when both CE and EE has partials with the same name'
do
let
(
:partial
)
{
'shared/issuable/form/default_templates'
}
let
(
:project
)
{
build_stubbed
(
:project
)
}
describe
'#render_ce'
do
before
do
helper
.
instance_variable_set
(
:@project
,
project
)
allow
(
project
).
to
receive
(
:feature_available?
)
end
it
'renders the CE partial'
do
helper
.
render_ce
(
partial
)
expect
(
project
).
not_to
receive
(
:feature_available?
)
end
end
describe
'#find_ce_partial'
do
let
(
:expected_partial_path
)
do
"app/views/
#{
File
.
dirname
(
partial
)
}
/_
#{
File
.
basename
(
partial
)
}
.html.haml"
end
it
'finds the CE partial'
do
ce_partial
=
helper
.
find_ce_partial
(
partial
)
expect
(
ce_partial
.
inspect
).
to
eq
(
expected_partial_path
)
# And it could still find the EE partial
ee_partial
=
helper
.
lookup_context
.
find
(
partial
,
[],
true
)
expect
(
ee_partial
.
inspect
).
to
eq
(
"ee/
#{
expected_partial_path
}
"
)
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