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
ae851edc
Commit
ae851edc
authored
Oct 10, 2016
by
Luke Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added no-template functionality
Added tests
parent
2362dfee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
8 deletions
+42
-8
app/assets/javascripts/templates/issuable_template_selector.js.es6
...s/javascripts/templates/issuable_template_selector.js.es6
+7
-1
app/views/shared/issuable/_form.html.haml
app/views/shared/issuable/_form.html.haml
+2
-0
spec/features/projects/issuable_templates_spec.rb
spec/features/projects/issuable_templates_spec.rb
+33
-7
No files found.
app/assets/javascripts/templates/issuable_template_selector.js.es6
View file @
ae851edc
...
...
@@ -16,7 +16,13 @@
if (initialQuery.name) this.requestFile(initialQuery);
$('.reset-template', this.dropdown.parent()).on('click', () => {
if (this.currentTemplate) this.setInputValueToTemplateContent(false);
this.setInputValueToTemplateContent();
});
$('.no-template', this.dropdown.parent()).on('click', () => {
this.currentTemplate = '';
this.setInputValueToTemplateContent();
$('.dropdown-toggle-text', this.dropdown).text('Choose a template');
});
}
...
...
app/views/shared/issuable/_form.html.haml
View file @
ae851edc
...
...
@@ -23,6 +23,8 @@
data:
{
data:
issuable_template_names
,
field_name:
'issuable_template'
,
selected:
selected_template
(
issuable
),
project_path:
ref_project
.
path
,
namespace_path:
ref_project
.
namespace
.
path
}
}
)
do
%ul
.dropdown-footer-list
%li
%a
.no-template
No template
%a
.reset-template
Reset template
%div
{
class:
issuable_template_names
.
any?
?
'col-sm-7 col-lg-8'
:
'col-sm-10'
}
...
...
spec/features/projects/issuable_templates_spec.rb
View file @
ae851edc
...
...
@@ -15,6 +15,7 @@ feature 'issuable templates', feature: true, js: true do
let
(
:template_content
)
{
'this is a test "bug" template'
}
let
(
:longtemplate_content
)
{
%Q(this
\n\n\n\n\n
is
\n\n\n\n\n
a
\n\n\n\n\n
bug
\n\n\n\n\n
template)
}
let
(
:issue
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project
)
}
let
(
:description_addition
)
{
' appending to description'
}
background
do
project
.
repository
.
commit_file
(
user
,
'.gitlab/issue_templates/bug.md'
,
template_content
,
'added issue template'
,
'master'
,
false
)
...
...
@@ -26,7 +27,26 @@ feature 'issuable templates', feature: true, js: true do
scenario
'user selects "bug" template'
do
select_template
'bug'
wait_for_ajax
preview_template
(
template_content
)
preview_template
save_changes
end
scenario
'user selects "bug" template and then "no template"'
do
select_template
'bug'
wait_for_ajax
select_option
'No template'
wait_for_ajax
preview_template
(
''
)
save_changes
(
''
)
end
scenario
'user selects "bug" template, edits description and then selects "reset template"'
do
select_template
'bug'
wait_for_ajax
find_field
(
'issue_description'
).
send_keys
(
description_addition
)
preview_template
(
template_content
+
description_addition
)
select_option
'Reset template'
preview_template
save_changes
end
...
...
@@ -37,7 +57,7 @@ feature 'issuable templates', feature: true, js: true do
wait_for_ajax
end_height
=
page
.
evaluate_script
(
'$(".markdown-area").outerHeight()'
)
expect
(
end_height
).
not_to
eq
(
start_height
)
end
end
...
...
@@ -75,7 +95,7 @@ feature 'issuable templates', feature: true, js: true do
scenario
'user selects "feature-proposal" template'
do
select_template
'feature-proposal'
wait_for_ajax
preview_template
(
template_content
)
preview_template
save_changes
end
end
...
...
@@ -102,25 +122,31 @@ feature 'issuable templates', feature: true, js: true do
scenario
'user selects template'
do
select_template
'feature-proposal'
wait_for_ajax
preview_template
(
template_content
)
preview_template
save_changes
end
end
end
end
def
preview_template
(
expected_content
)
def
preview_template
(
expected_content
=
template_content
)
click_link
'Preview'
expect
(
page
).
to
have_content
expected_content
click_link
'Write'
end
def
save_changes
def
save_changes
(
expected_content
=
template_content
)
click_button
"Save changes"
expect
(
page
).
to
have_content
template
_content
expect
(
page
).
to
have_content
expected
_content
end
def
select_template
(
name
)
first
(
'.js-issuable-selector'
).
click
first
(
'.js-issuable-selector-wrap .dropdown-content a'
,
text:
name
).
click
end
def
select_option
(
name
)
first
(
'.js-issuable-selector'
).
click
first
(
'.js-issuable-selector-wrap .dropdown-footer-list a'
,
text:
name
).
click
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