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
Léo-Paul Géneau
gitlab-ce
Commits
4b6e583c
Commit
4b6e583c
authored
Jan 12, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds test suite
parent
cd51af1a
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
17 additions
and
147 deletions
+17
-147
app/helpers/services_helper.rb
app/helpers/services_helper.rb
+2
-0
app/models/project_services/asana_service.rb
app/models/project_services/asana_service.rb
+0
-4
app/models/project_services/assembla_service.rb
app/models/project_services/assembla_service.rb
+0
-4
app/models/project_services/bamboo_service.rb
app/models/project_services/bamboo_service.rb
+0
-4
app/models/project_services/bugzilla_service.rb
app/models/project_services/bugzilla_service.rb
+0
-8
app/models/project_services/buildkite_service.rb
app/models/project_services/buildkite_service.rb
+0
-8
app/models/project_services/builds_email_service.rb
app/models/project_services/builds_email_service.rb
+0
-4
app/models/project_services/campfire_service.rb
app/models/project_services/campfire_service.rb
+0
-4
app/models/project_services/ci_service.rb
app/models/project_services/ci_service.rb
+0
-3
app/models/project_services/custom_issue_tracker_service.rb
app/models/project_services/custom_issue_tracker_service.rb
+0
-8
app/models/project_services/emails_on_push_service.rb
app/models/project_services/emails_on_push_service.rb
+0
-4
app/models/project_services/external_wiki_service.rb
app/models/project_services/external_wiki_service.rb
+0
-4
app/models/project_services/flowdock_service.rb
app/models/project_services/flowdock_service.rb
+0
-4
app/models/project_services/gemnasium_service.rb
app/models/project_services/gemnasium_service.rb
+0
-4
app/models/project_services/hipchat_service.rb
app/models/project_services/hipchat_service.rb
+0
-4
app/models/project_services/irker_service.rb
app/models/project_services/irker_service.rb
+0
-4
app/models/project_services/jira_service.rb
app/models/project_services/jira_service.rb
+0
-4
app/models/project_services/kubernetes_service.rb
app/models/project_services/kubernetes_service.rb
+0
-8
app/models/project_services/mattermost_service.rb
app/models/project_services/mattermost_service.rb
+0
-8
app/models/project_services/mattermost_slash_commands_service.rb
...els/project_services/mattermost_slash_commands_service.rb
+0
-8
app/models/project_services/pipelines_email_service.rb
app/models/project_services/pipelines_email_service.rb
+0
-4
app/models/project_services/pivotaltracker_service.rb
app/models/project_services/pivotaltracker_service.rb
+0
-4
app/models/project_services/pushover_service.rb
app/models/project_services/pushover_service.rb
+0
-4
app/models/project_services/redmine_service.rb
app/models/project_services/redmine_service.rb
+0
-8
app/models/project_services/slack_service.rb
app/models/project_services/slack_service.rb
+0
-8
app/models/project_services/slack_slash_commands_service.rb
app/models/project_services/slack_slash_commands_service.rb
+0
-8
app/models/project_services/teamcity_service.rb
app/models/project_services/teamcity_service.rb
+0
-8
app/models/service.rb
app/models/service.rb
+12
-1
lib/api/services.rb
lib/api/services.rb
+2
-3
spec/controllers/projects/services_controller_spec.rb
spec/controllers/projects/services_controller_spec.rb
+1
-0
No files found.
app/helpers/services_helper.rb
View file @
4b6e583c
...
@@ -26,4 +26,6 @@ module ServicesHelper
...
@@ -26,4 +26,6 @@ module ServicesHelper
event
=
event
.
pluralize
if
%w[merge_request issue confidential_issue]
.
include?
(
event
)
event
=
event
.
pluralize
if
%w[merge_request issue confidential_issue]
.
include?
(
event
)
"
#{
event
}
_events"
"
#{
event
}
_events"
end
end
extend
self
end
end
app/models/project_services/asana_service.rb
View file @
4b6e583c
...
@@ -48,10 +48,6 @@ http://app.asana.com/-/account_api'
...
@@ -48,10 +48,6 @@ http://app.asana.com/-/account_api'
%w(push)
%w(push)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
client
def
client
@_client
||=
begin
@_client
||=
begin
Asana
::
Client
.
new
do
|
c
|
Asana
::
Client
.
new
do
|
c
|
...
...
app/models/project_services/assembla_service.rb
View file @
4b6e583c
...
@@ -27,10 +27,6 @@ class AssemblaService < Service
...
@@ -27,10 +27,6 @@ class AssemblaService < Service
%w(push)
%w(push)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
execute
(
data
)
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
...
...
app/models/project_services/bamboo_service.rb
View file @
4b6e583c
...
@@ -56,10 +56,6 @@ class BambooService < CiService
...
@@ -56,10 +56,6 @@ class BambooService < CiService
]
]
end
end
def
self
.
supported_events
%w(push)
end
def
build_page
(
sha
,
ref
)
def
build_page
(
sha
,
ref
)
with_reactive_cache
(
sha
,
ref
)
{
|
cached
|
cached
[
:build_page
]
}
with_reactive_cache
(
sha
,
ref
)
{
|
cached
|
cached
[
:build_page
]
}
end
end
...
...
app/models/project_services/bugzilla_service.rb
View file @
4b6e583c
...
@@ -22,12 +22,4 @@ class BugzillaService < IssueTrackerService
...
@@ -22,12 +22,4 @@ class BugzillaService < IssueTrackerService
def
self
.
to_param
def
self
.
to_param
'bugzilla'
'bugzilla'
end
end
def
self
.
supported_events
%w()
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
end
end
app/models/project_services/buildkite_service.rb
View file @
4b6e583c
...
@@ -24,14 +24,6 @@ class BuildkiteService < CiService
...
@@ -24,14 +24,6 @@ class BuildkiteService < CiService
hook
.
save
hook
.
save
end
end
def
self
.
supported_events
%w(push)
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
execute
(
data
)
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
...
...
app/models/project_services/builds_email_service.rb
View file @
4b6e583c
...
@@ -27,10 +27,6 @@ class BuildsEmailService < Service
...
@@ -27,10 +27,6 @@ class BuildsEmailService < Service
%w(build)
%w(build)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
execute
(
push_data
)
def
execute
(
push_data
)
return
unless
supported_events
.
include?
(
push_data
[
:object_kind
])
return
unless
supported_events
.
include?
(
push_data
[
:object_kind
])
return
unless
should_build_be_notified?
(
push_data
)
return
unless
should_build_be_notified?
(
push_data
)
...
...
app/models/project_services/campfire_service.rb
View file @
4b6e583c
...
@@ -28,10 +28,6 @@ class CampfireService < Service
...
@@ -28,10 +28,6 @@ class CampfireService < Service
%w(push)
%w(push)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
execute
(
data
)
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
...
...
app/models/project_services/ci_service.rb
View file @
4b6e583c
...
@@ -12,9 +12,6 @@ class CiService < Service
...
@@ -12,9 +12,6 @@ class CiService < Service
%w(push)
%w(push)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
# Return complete url to build page
# Return complete url to build page
#
#
# Ex.
# Ex.
...
...
app/models/project_services/custom_issue_tracker_service.rb
View file @
4b6e583c
...
@@ -36,12 +36,4 @@ class CustomIssueTrackerService < IssueTrackerService
...
@@ -36,12 +36,4 @@ class CustomIssueTrackerService < IssueTrackerService
{
type:
'text'
,
name:
'new_issue_url'
,
placeholder:
'New Issue url'
}
{
type:
'text'
,
name:
'new_issue_url'
,
placeholder:
'New Issue url'
}
]
]
end
end
def
self
.
supported_events
%w()
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
end
end
app/models/project_services/emails_on_push_service.rb
View file @
4b6e583c
...
@@ -20,10 +20,6 @@ class EmailsOnPushService < Service
...
@@ -20,10 +20,6 @@ class EmailsOnPushService < Service
%w(push tag_push)
%w(push tag_push)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
execute
(
push_data
)
def
execute
(
push_data
)
return
unless
supported_events
.
include?
(
push_data
[
:object_kind
])
return
unless
supported_events
.
include?
(
push_data
[
:object_kind
])
...
...
app/models/project_services/external_wiki_service.rb
View file @
4b6e583c
...
@@ -33,8 +33,4 @@ class ExternalWikiService < Service
...
@@ -33,8 +33,4 @@ class ExternalWikiService < Service
def
self
.
supported_events
def
self
.
supported_events
%w()
%w()
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
end
end
app/models/project_services/flowdock_service.rb
View file @
4b6e583c
...
@@ -26,10 +26,6 @@ class FlowdockService < Service
...
@@ -26,10 +26,6 @@ class FlowdockService < Service
%w(push)
%w(push)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
execute
(
data
)
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
...
...
app/models/project_services/gemnasium_service.rb
View file @
4b6e583c
...
@@ -27,10 +27,6 @@ class GemnasiumService < Service
...
@@ -27,10 +27,6 @@ class GemnasiumService < Service
%w(push)
%w(push)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
execute
(
data
)
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
...
...
app/models/project_services/hipchat_service.rb
View file @
4b6e583c
...
@@ -49,10 +49,6 @@ class HipchatService < Service
...
@@ -49,10 +49,6 @@ class HipchatService < Service
%w(push issue confidential_issue merge_request note tag_push build)
%w(push issue confidential_issue merge_request note tag_push build)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
execute
(
data
)
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
message
=
create_message
(
data
)
message
=
create_message
(
data
)
...
...
app/models/project_services/irker_service.rb
View file @
4b6e583c
...
@@ -25,10 +25,6 @@ class IrkerService < Service
...
@@ -25,10 +25,6 @@ class IrkerService < Service
%w(push)
%w(push)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
execute
(
data
)
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
...
...
app/models/project_services/jira_service.rb
View file @
4b6e583c
...
@@ -16,10 +16,6 @@ class JiraService < IssueTrackerService
...
@@ -16,10 +16,6 @@ class JiraService < IssueTrackerService
%w(commit merge_request)
%w(commit merge_request)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
# {PROJECT-KEY}-{NUMBER} Examples: JIRA-1, PROJECT-1
# {PROJECT-KEY}-{NUMBER} Examples: JIRA-1, PROJECT-1
def
reference_pattern
def
reference_pattern
@reference_pattern
||=
%r{(?<issue>
\b
([A-Z][A-Z0-9_]+-)
\d
+)}
@reference_pattern
||=
%r{(?<issue>
\b
([A-Z][A-Z0-9_]+-)
\d
+)}
...
...
app/models/project_services/kubernetes_service.rb
View file @
4b6e583c
...
@@ -158,14 +158,6 @@ class KubernetesService < DeploymentService
...
@@ -158,14 +158,6 @@ class KubernetesService < DeploymentService
opts
opts
end
end
def
self
.
supported_events
%w()
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
kubeclient_auth_options
def
kubeclient_auth_options
{
bearer_token:
token
}
{
bearer_token:
token
}
end
end
...
...
app/models/project_services/mattermost_service.rb
View file @
4b6e583c
...
@@ -38,12 +38,4 @@ class MattermostService < ChatNotificationService
...
@@ -38,12 +38,4 @@ class MattermostService < ChatNotificationService
def
default_channel_placeholder
def
default_channel_placeholder
"#town-square"
"#town-square"
end
end
def
self
.
supported_events
%w()
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
end
end
app/models/project_services/mattermost_slash_commands_service.rb
View file @
4b6e583c
...
@@ -48,12 +48,4 @@ class MattermostSlashCommandsService < ChatSlashCommandsService
...
@@ -48,12 +48,4 @@ class MattermostSlashCommandsService < ChatSlashCommandsService
method:
'P'
,
method:
'P'
,
username:
'GitLab'
)
username:
'GitLab'
)
end
end
def
self
.
supported_events
%w()
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
end
end
app/models/project_services/pipelines_email_service.rb
View file @
4b6e583c
...
@@ -23,10 +23,6 @@ class PipelinesEmailService < Service
...
@@ -23,10 +23,6 @@ class PipelinesEmailService < Service
%w[pipeline]
%w[pipeline]
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
execute
(
data
,
force:
false
)
def
execute
(
data
,
force:
false
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
force
||
should_pipeline_be_notified?
(
data
)
return
unless
force
||
should_pipeline_be_notified?
(
data
)
...
...
app/models/project_services/pivotaltracker_service.rb
View file @
4b6e583c
...
@@ -38,10 +38,6 @@ class PivotaltrackerService < Service
...
@@ -38,10 +38,6 @@ class PivotaltrackerService < Service
%w(push)
%w(push)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
execute
(
data
)
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
allowed_branch?
(
data
[
:ref
])
return
unless
allowed_branch?
(
data
[
:ref
])
...
...
app/models/project_services/pushover_service.rb
View file @
4b6e583c
...
@@ -65,10 +65,6 @@ class PushoverService < Service
...
@@ -65,10 +65,6 @@ class PushoverService < Service
%w(push)
%w(push)
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
execute
(
data
)
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
...
...
app/models/project_services/redmine_service.rb
View file @
4b6e583c
...
@@ -22,12 +22,4 @@ class RedmineService < IssueTrackerService
...
@@ -22,12 +22,4 @@ class RedmineService < IssueTrackerService
def
self
.
to_param
def
self
.
to_param
'redmine'
'redmine'
end
end
def
self
.
supported_events
%w()
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
end
end
app/models/project_services/slack_service.rb
View file @
4b6e583c
...
@@ -37,12 +37,4 @@ class SlackService < ChatNotificationService
...
@@ -37,12 +37,4 @@ class SlackService < ChatNotificationService
def
default_channel_placeholder
def
default_channel_placeholder
"#general"
"#general"
end
end
def
self
.
supported_events
%w()
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
end
end
app/models/project_services/slack_slash_commands_service.rb
View file @
4b6e583c
...
@@ -25,12 +25,4 @@ class SlackSlashCommandsService < ChatSlashCommandsService
...
@@ -25,12 +25,4 @@ class SlackSlashCommandsService < ChatSlashCommandsService
def
format
(
text
)
def
format
(
text
)
Slack
::
Notifier
::
LinkFormatter
.
format
(
text
)
if
text
Slack
::
Notifier
::
LinkFormatter
.
format
(
text
)
if
text
end
end
def
self
.
supported_events
%w()
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
end
end
app/models/project_services/teamcity_service.rb
View file @
4b6e583c
...
@@ -47,14 +47,6 @@ class TeamcityService < CiService
...
@@ -47,14 +47,6 @@ class TeamcityService < CiService
'teamcity'
'teamcity'
end
end
def
self
.
supported_events
%w(push)
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'teamcity_url'
,
{
type:
'text'
,
name:
'teamcity_url'
,
...
...
app/models/service.rb
View file @
4b6e583c
...
@@ -79,6 +79,10 @@ class Service < ActiveRecord::Base
...
@@ -79,6 +79,10 @@ class Service < ActiveRecord::Base
self
.
class
.
to_param
self
.
class
.
to_param
end
end
def
self
.
to_param
raise
NotImplementedError
end
def
fields
def
fields
# implement inside child
# implement inside child
[]
[]
...
@@ -93,10 +97,13 @@ class Service < ActiveRecord::Base
...
@@ -93,10 +97,13 @@ class Service < ActiveRecord::Base
end
end
def
event_names
def
event_names
# implement inside child
self
.
class
.
event_names
self
.
class
.
event_names
end
end
def
self
.
event_names
self
.
supported_events
.
map
{
|
event
|
"
#{
event
}
_events"
}
end
def
event_field
(
event
)
def
event_field
(
event
)
nil
nil
end
end
...
@@ -109,6 +116,10 @@ class Service < ActiveRecord::Base
...
@@ -109,6 +116,10 @@ class Service < ActiveRecord::Base
self
.
class
.
supported_events
self
.
class
.
supported_events
end
end
def
self
.
supported_events
%w(push tag_push issue confidential_issue merge_request wiki_page)
end
def
execute
(
data
)
def
execute
(
data
)
# implement inside child
# implement inside child
end
end
...
...
lib/api/services.rb
View file @
4b6e583c
...
@@ -600,12 +600,11 @@ module API
...
@@ -600,12 +600,11 @@ module API
service_classes
.
each
do
|
service
|
service_classes
.
each
do
|
service
|
event_names
=
service
.
try
(
:event_names
)
||
[]
event_names
=
service
.
try
(
:event_names
)
||
[]
event_names
.
each
do
|
event_name
|
event_names
.
each
do
|
event_name
|
services
[
service
.
to_param
.
gsub
(
"_"
,
"-"
)]
<<
{
services
[
service
.
to_param
.
tr
(
"_"
,
"-"
)]
<<
{
required:
false
,
required:
false
,
name:
event_name
.
to_sym
,
name:
event_name
.
to_sym
,
type:
String
,
type:
String
,
desc:
ServicesHelper
.
instance_method
(
:service_event_description
)
desc:
ServicesHelper
.
service_event_description
(
event_name
)
.
bind
(
self
).
call
(
event_name
)
}
}
end
end
end
end
...
...
spec/controllers/projects/services_controller_spec.rb
View file @
4b6e583c
...
@@ -54,6 +54,7 @@ describe Projects::ServicesController do
...
@@ -54,6 +54,7 @@ describe Projects::ServicesController do
context
'on successful update'
do
context
'on successful update'
do
it
'sets the flash'
do
it
'sets the flash'
do
expect
(
service
).
to
receive
(
:to_param
).
and_return
(
'hipchat'
)
expect
(
service
).
to
receive
(
:to_param
).
and_return
(
'hipchat'
)
expect
(
service
).
to
receive
(
:event_names
).
and_return
(
HipchatService
.
event_names
)
put
:update
,
put
:update
,
namespace_id:
project
.
namespace
.
id
,
namespace_id:
project
.
namespace
.
id
,
...
...
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