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
185451c9
Commit
185451c9
authored
Feb 05, 2020
by
Justin Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow multiple Slack channels for notifications
parent
4c595e9d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
2 deletions
+43
-2
app/models/project_services/chat_notification_service.rb
app/models/project_services/chat_notification_service.rb
+2
-2
changelogs/unreleased/14080-slack-multiple-channels.yml
changelogs/unreleased/14080-slack-multiple-channels.yml
+5
-0
spec/models/project_services/chat_notification_service_spec.rb
...models/project_services/chat_notification_service_spec.rb
+36
-0
No files found.
app/models/project_services/chat_notification_service.rb
View file @
185451c9
...
...
@@ -84,10 +84,10 @@ class ChatNotificationService < Service
event_type
=
data
[
:event_type
]
||
object_kind
channel_name
=
get_channel_field
(
event_type
).
presence
||
channel
channel_name
s
=
get_channel_field
(
event_type
).
presence
||
channel
opts
=
{}
opts
[
:channel
]
=
channel_name
if
channel_name
opts
[
:channel
]
=
channel_name
s
.
split
(
','
).
map
(
&
:strip
)
if
channel_names
opts
[
:username
]
=
username
if
username
return
false
unless
notify
(
message
,
opts
)
...
...
changelogs/unreleased/14080-slack-multiple-channels.yml
0 → 100644
View file @
185451c9
---
title
:
Allow multiple Slack channels for notifications
merge_request
:
24132
author
:
type
:
added
spec/models/project_services/chat_notification_service_spec.rb
View file @
185451c9
...
...
@@ -74,5 +74,41 @@ describe ChatNotificationService do
chat_service
.
execute
(
data
)
end
end
context
'with channel specified'
do
let
(
:channel1
)
{
'slack-integration'
}
let
(
:channel2
)
{
'#slack-test'
}
before
do
allow
(
chat_service
).
to
receive
(
:push_channel
).
and_return
(
channel
)
end
context
'with single channel name'
do
let
(
:channel
)
{
channel1
}
it
'notifies one channel'
do
expect
(
chat_service
).
to
receive
(
:notify
).
with
(
any_args
,
hash_including
(
channel:
[
channel1
])).
and_return
(
true
)
expect
(
chat_service
.
execute
(
data
)).
to
be
(
true
)
end
end
context
'with multiple channel names'
do
let
(
:channel
)
{
[
channel1
,
channel2
].
join
(
','
)
}
it
'notifies all channels'
do
expect
(
chat_service
).
to
receive
(
:notify
).
with
(
any_args
,
hash_including
(
channel:
[
channel1
,
channel2
])).
and_return
(
true
)
expect
(
chat_service
.
execute
(
data
)).
to
be
(
true
)
end
end
context
'with multiple channel names with spaces'
do
let
(
:channel
)
{
[
channel1
,
channel2
].
join
(
', '
)
}
it
'notifies all channels'
do
expect
(
chat_service
).
to
receive
(
:notify
).
with
(
any_args
,
hash_including
(
channel:
[
channel1
,
channel2
])).
and_return
(
true
)
expect
(
chat_service
.
execute
(
data
)).
to
be
(
true
)
end
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