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
ac8d1f74
Commit
ac8d1f74
authored
Feb 17, 2020
by
Justin Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use shared examples for chat_notification_service_spec
parent
7f5fe388
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
26 deletions
+13
-26
spec/models/project_services/chat_notification_service_spec.rb
...models/project_services/chat_notification_service_spec.rb
+13
-26
No files found.
spec/models/project_services/chat_notification_service_spec.rb
View file @
ac8d1f74
...
...
@@ -75,40 +75,27 @@ describe ChatNotificationService do
end
end
context
'with channel specified'
do
let
(
:channel1
)
{
'slack-integration'
}
let
(
:channel2
)
{
'#slack-test'
}
shared_examples
'with channel specified'
do
|
channel
,
expected_channels
|
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
it
'notifies all channels'
do
expect
(
chat_service
).
to
receive
(
:notify
).
with
(
any_args
,
hash_including
(
channel:
expected_channels
)).
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 single channel specified'
do
it_behaves_like
'with channel specified'
,
'slack-integration'
,
[
'slack-integration'
]
end
context
'with multiple channel names with spaces'
do
let
(
:channel
)
{
[
channel1
,
channel2
].
join
(
', '
)
}
context
'with multiple channel names specified'
do
it_behaves_like
'with channel specified'
,
'slack-integration,#slack-test'
,
[
'slack-integration'
,
'#slack-test'
]
end
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 specified'
do
it_behaves_like
'with channel specified'
,
'slack-integration, #slack-test, @UDLP91W0A'
,
[
'slack-integration'
,
'#slack-test'
,
'@UDLP91W0A'
]
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