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
2ee19708
Commit
2ee19708
authored
Mar 16, 2018
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve JIRA event descriptions
parent
9fd2d9ea
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
88 additions
and
29 deletions
+88
-29
app/helpers/services_helper.rb
app/helpers/services_helper.rb
+0
-23
app/models/project_services/jira_service.rb
app/models/project_services/jira_service.rb
+11
-3
app/models/service.rb
app/models/service.rb
+23
-0
app/views/shared/_service_settings.html.haml
app/views/shared/_service_settings.html.haml
+1
-1
changelogs/unreleased/issue_25542.yml
changelogs/unreleased/issue_25542.yml
+5
-0
lib/api/services.rb
lib/api/services.rb
+1
-1
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+1
-1
spec/views/projects/services/_form.haml_spec.rb
spec/views/projects/services/_form.haml_spec.rb
+46
-0
No files found.
app/helpers/services_helper.rb
View file @
2ee19708
module
ServicesHelper
def
service_event_description
(
event
)
case
event
when
"push"
,
"push_events"
"Event will be triggered by a push to the repository"
when
"tag_push"
,
"tag_push_events"
"Event will be triggered when a new tag is pushed to the repository"
when
"note"
,
"note_events"
"Event will be triggered when someone adds a comment"
when
"issue"
,
"issue_events"
"Event will be triggered when an issue is created/updated/closed"
when
"confidential_issue"
,
"confidential_issue_events"
"Event will be triggered when a confidential issue is created/updated/closed"
when
"merge_request"
,
"merge_request_events"
"Event will be triggered when a merge request is created/updated/merged"
when
"pipeline"
,
"pipeline_events"
"Event will be triggered when a pipeline status changes"
when
"wiki_page"
,
"wiki_page_events"
"Event will be triggered when a wiki page is created/updated"
when
"commit"
,
"commit_events"
"Event will be triggered when a commit is created/updated"
end
end
def
service_event_field_name
(
event
)
event
=
event
.
pluralize
if
%w[merge_request issue confidential_issue]
.
include?
(
event
)
"
#{
event
}
_events"
...
...
app/models/project_services/jira_service.rb
View file @
2ee19708
...
...
@@ -14,9 +14,8 @@ class JiraService < IssueTrackerService
alias_method
:project_url
,
:url
# This is confusing, but JiraService does not really support these events.
# The values here are required to display correct options in the service
# configuration screen.
# When these are false GitLab does not create cross reference
# comments on JIRA except when an issue gets transitioned.
def
self
.
supported_events
%w(commit merge_request)
end
...
...
@@ -318,4 +317,13 @@ class JiraService < IssueTrackerService
url_changed?
end
def
self
.
event_description
(
event
)
case
event
when
"merge_request"
,
"merge_request_events"
"JIRA comments will be created when an issue gets referenced in a merge request."
when
"commit"
,
"commit_events"
"JIRA comments will be created when an issue gets referenced in a commit."
end
end
end
app/models/service.rb
View file @
2ee19708
...
...
@@ -304,6 +304,29 @@ class Service < ActiveRecord::Base
end
end
def
self
.
event_description
(
event
)
case
event
when
"push"
,
"push_events"
"Event will be triggered by a push to the repository"
when
"tag_push"
,
"tag_push_events"
"Event will be triggered when a new tag is pushed to the repository"
when
"note"
,
"note_events"
"Event will be triggered when someone adds a comment"
when
"issue"
,
"issue_events"
"Event will be triggered when an issue is created/updated/closed"
when
"confidential_issue"
,
"confidential_issue_events"
"Event will be triggered when a confidential issue is created/updated/closed"
when
"merge_request"
,
"merge_request_events"
"Event will be triggered when a merge request is created/updated/merged"
when
"pipeline"
,
"pipeline_events"
"Event will be triggered when a pipeline status changes"
when
"wiki_page"
,
"wiki_page_events"
"Event will be triggered when a wiki page is created/updated"
when
"commit"
,
"commit_events"
"Event will be triggered when a commit is created/updated"
end
end
def
valid_recipients?
activated?
&&
!
importing?
end
...
...
app/views/shared/_service_settings.html.haml
View file @
2ee19708
...
...
@@ -33,7 +33,7 @@
=
form
.
text_field
field
[
:name
],
class:
"form-control"
,
placeholder:
field
[
:placeholder
]
%p
.light
=
service_
event_description
(
event
)
=
@service
.
class
.
event_description
(
event
)
-
@service
.
global_fields
.
each
do
|
field
|
-
type
=
field
[
:type
]
...
...
changelogs/unreleased/issue_25542.yml
0 → 100644
View file @
2ee19708
---
title
:
Improve JIRA event descriptions
merge_request
:
author
:
type
:
other
lib/api/services.rb
View file @
2ee19708
...
...
@@ -735,7 +735,7 @@ module API
required:
false
,
name:
event_name
.
to_sym
,
type:
String
,
desc:
ServicesHelper
.
service_
event_description
(
event_name
)
desc:
service
.
event_description
(
event_name
)
}
end
end
...
...
spec/services/system_note_service_spec.rb
View file @
2ee19708
...
...
@@ -743,7 +743,7 @@ describe SystemNoteService do
expect
(
cross_reference
(
type
)).
to
eq
(
"Events for
#{
type
.
pluralize
.
humanize
.
downcase
}
are disabled."
)
end
it
"
block
s cross reference when
#{
type
.
underscore
}
_events is true"
do
it
"
create
s cross reference when
#{
type
.
underscore
}
_events is true"
do
jira_tracker
.
update
(
"
#{
type
}
_events"
=>
true
)
expect
(
cross_reference
(
type
)).
to
eq
(
success_message
)
...
...
spec/views/projects/services/_form.haml_spec.rb
0 → 100644
View file @
2ee19708
require
'spec_helper'
describe
'projects/services/_form'
do
let
(
:project
)
{
create
(
:redmine_project
)
}
let
(
:user
)
{
create
(
:admin
)
}
before
do
assign
(
:project
,
project
)
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
view
).
to
receive_messages
(
current_user:
user
,
can?:
true
,
current_application_settings:
Gitlab
::
CurrentSettings
.
current_application_settings
)
end
context
'commit_events and merge_request_events'
do
before
do
assign
(
:service
,
project
.
redmine_service
)
end
it
'display merge_request_events and commit_events descriptions'
do
allow
(
RedmineService
).
to
receive
(
:supported_events
).
and_return
(
%w(commit merge_request)
)
render
expect
(
rendered
).
to
have_content
(
'Event will be triggered when a commit is created/updated'
)
expect
(
rendered
).
to
have_content
(
'Event will be triggered when a merge request is created/updated/merged'
)
end
context
'when service is JIRA'
do
let
(
:project
)
{
create
(
:jira_project
)
}
before
do
assign
(
:service
,
project
.
jira_service
)
end
it
'display merge_request_events and commit_events descriptions'
do
render
expect
(
rendered
).
to
have_content
(
'JIRA comments will be created when an issue gets referenced in a commit.'
)
expect
(
rendered
).
to
have_content
(
'JIRA comments will be created when an issue gets referenced in a merge request.'
)
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