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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
9c6fc59c
Commit
9c6fc59c
authored
Jul 28, 2018
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support "Preview" tab also for commit commands
parent
9b95fe78
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
8 deletions
+29
-8
app/services/preview_markdown_service.rb
app/services/preview_markdown_service.rb
+4
-8
spec/services/preview_markdown_service_spec.rb
spec/services/preview_markdown_service_spec.rb
+25
-0
No files found.
app/services/preview_markdown_service.rb
View file @
9c6fc59c
...
...
@@ -16,7 +16,7 @@ class PreviewMarkdownService < BaseService
private
def
explain_quick_actions
(
text
)
return
text
,
[]
unless
%w(Issue MergeRequest)
.
include?
(
commands_target_type
)
return
text
,
[]
unless
%w(Issue MergeRequest
Commit
)
.
include?
(
commands_target_type
)
quick_actions_service
=
QuickActions
::
InterpretService
.
new
(
project
,
current_user
)
quick_actions_service
.
explain
(
text
,
find_commands_target
)
...
...
@@ -29,13 +29,9 @@ class PreviewMarkdownService < BaseService
end
def
find_commands_target
if
commands_target_id
.
present?
finder
=
commands_target_type
==
'Issue'
?
IssuesFinder
:
MergeRequestsFinder
finder
.
new
(
current_user
,
project_id:
project
.
id
).
find
(
commands_target_id
)
else
collection
=
commands_target_type
==
'Issue'
?
project
.
issues
:
project
.
merge_requests
collection
.
build
end
Projects
::
AutocompleteService
.
new
(
project
,
current_user
)
.
target
(
commands_target_type
,
commands_target_id
)
end
def
commands_target_type
...
...
spec/services/preview_markdown_service_spec.rb
View file @
9c6fc59c
...
...
@@ -65,6 +65,31 @@ describe PreviewMarkdownService do
end
end
context
'commit description'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:commit
)
{
project
.
commit
}
let
(
:params
)
do
{
text:
"My work
\n
/tag v1.2.3 Stable release"
,
quick_actions_target_type:
'Commit'
,
quick_actions_target_id:
commit
.
id
}
end
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
params
)
}
it
'removes quick actions from text'
do
result
=
service
.
execute
expect
(
result
[
:text
]).
to
eq
'My work'
end
it
'explains quick actions effect'
do
result
=
service
.
execute
expect
(
result
[
:commands
]).
to
eq
'Tags this commit to v1.2.3 with "Stable release".'
end
end
it
'sets correct markdown engine'
do
service
=
described_class
.
new
(
project
,
user
,
{
markdown_version:
CacheMarkdownField
::
CACHE_REDCARPET_VERSION
})
result
=
service
.
execute
...
...
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