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
39c48dde
Commit
39c48dde
authored
Mar 08, 2021
by
Andy Soiron
Committed by
Luke Duncalfe
Mar 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add context for tag push to slack mattermost tests
parent
6c9c3b7e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
30 deletions
+27
-30
spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb
.../models/slack_mattermost_notifications_shared_examples.rb
+27
-30
No files found.
spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb
View file @
39c48dde
...
@@ -79,6 +79,18 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
...
@@ -79,6 +79,18 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
subject
(
:execute_service
)
{
chat_service
.
execute
(
data
)
}
subject
(
:execute_service
)
{
chat_service
.
execute
(
data
)
}
shared_examples
'calls the service API with the event message'
do
|
event_message
|
specify
do
expect_next_instance_of
(
Slack
::
Messenger
)
do
|
messenger
|
expect
(
messenger
).
to
receive
(
:ping
).
with
(
event_message
,
anything
).
and_call_original
end
execute_service
expect
(
WebMock
).
to
have_requested
(
:post
,
stubbed_resolved_hostname
).
once
end
end
context
'with username for slack configured'
do
context
'with username for slack configured'
do
let
(
:chat_service_params
)
{
{
username:
'slack_username'
}
}
let
(
:chat_service_params
)
{
{
username:
'slack_username'
}
}
...
@@ -92,11 +104,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
...
@@ -92,11 +104,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
context
'push events'
do
context
'push events'
do
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
project
,
user
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
project
,
user
)
}
it
"calls
#{
service_name
}
API for push events"
do
it_behaves_like
'calls the service API with the event message'
,
/pushed to branch/
execute_service
expect
(
WebMock
).
to
have_requested
(
:post
,
stubbed_resolved_hostname
).
once
end
context
'with event channel'
do
context
'with event channel'
do
let
(
:chat_service_params
)
{
{
push_channel:
'random'
}
}
let
(
:chat_service_params
)
{
{
push_channel:
'random'
}
}
...
@@ -109,15 +117,20 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
...
@@ -109,15 +117,20 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
end
end
end
end
context
'tag_push events'
do
let
(
:oldrev
)
{
Gitlab
::
Git
::
BLANK_SHA
}
let
(
:newrev
)
{
'8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b'
}
# gitlab-test: git rev-parse refs/tags/v1.1.0
let
(
:ref
)
{
'refs/tags/v1.1.0'
}
let
(
:data
)
{
Git
::
TagHooksService
.
new
(
project
,
user
,
change:
{
oldrev:
oldrev
,
newrev:
newrev
,
ref:
ref
}).
send
(
:push_data
)
}
it_behaves_like
'calls the service API with the event message'
,
/pushed new tag/
end
context
'issue events'
do
context
'issue events'
do
let_it_be
(
:issue
)
{
create
(
:issue
)
}
let_it_be
(
:issue
)
{
create
(
:issue
)
}
let
(
:data
)
{
issue
.
to_hook_data
(
user
)
}
let
(
:data
)
{
issue
.
to_hook_data
(
user
)
}
it
"calls
#{
service_name
}
API for issue events"
do
it_behaves_like
'calls the service API with the event message'
,
/Issue (.*?) opened by/
execute_service
expect
(
WebMock
).
to
have_requested
(
:post
,
stubbed_resolved_hostname
).
once
end
context
'whith event channel'
do
context
'whith event channel'
do
let
(
:chat_service_params
)
{
{
issue_channel:
'random'
}
}
let
(
:chat_service_params
)
{
{
issue_channel:
'random'
}
}
...
@@ -156,11 +169,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
...
@@ -156,11 +169,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
let_it_be
(
:merge_request
)
{
create
(
:merge_request
)
}
let_it_be
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:data
)
{
merge_request
.
to_hook_data
(
user
)
}
let
(
:data
)
{
merge_request
.
to_hook_data
(
user
)
}
it
"calls
#{
service_name
}
API for merge requests events"
do
it_behaves_like
'calls the service API with the event message'
,
/opened merge request/
execute_service
expect
(
WebMock
).
to
have_requested
(
:post
,
stubbed_resolved_hostname
).
once
end
context
'with event channel'
do
context
'with event channel'
do
let
(
:chat_service_params
)
{
{
merge_request_channel:
'random'
}
}
let
(
:chat_service_params
)
{
{
merge_request_channel:
'random'
}
}
...
@@ -177,11 +186,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
...
@@ -177,11 +186,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
let_it_be
(
:wiki_page
)
{
create
(
:wiki_page
,
wiki:
project
.
wiki
,
message:
'user created page: Awesome wiki_page'
)
}
let_it_be
(
:wiki_page
)
{
create
(
:wiki_page
,
wiki:
project
.
wiki
,
message:
'user created page: Awesome wiki_page'
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
WikiPage
.
build
(
wiki_page
,
user
,
'create'
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
WikiPage
.
build
(
wiki_page
,
user
,
'create'
)
}
it
"calls
#{
service_name
}
API for wiki page events"
do
it_behaves_like
'calls the service API with the event message'
,
/ created (.*?)wikis\/(.*?)|wiki page> in/
execute_service
expect
(
WebMock
).
to
have_requested
(
:post
,
stubbed_resolved_hostname
).
once
end
context
'with event channel'
do
context
'with event channel'
do
let
(
:chat_service_params
)
{
{
wiki_page_channel:
'random'
}
}
let
(
:chat_service_params
)
{
{
wiki_page_channel:
'random'
}
}
...
@@ -198,22 +203,14 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
...
@@ -198,22 +203,14 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
let_it_be
(
:deployment
)
{
create
(
:deployment
)
}
let_it_be
(
:deployment
)
{
create
(
:deployment
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Deployment
.
build
(
deployment
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Deployment
.
build
(
deployment
)
}
it
"calls
#{
service_name
}
API for deployment events"
do
it_behaves_like
'calls the service API with the event message'
,
/Deploy to (.*?) created/
execute_service
expect
(
WebMock
).
to
have_requested
(
:post
,
stubbed_resolved_hostname
).
once
end
end
end
context
'note event'
do
context
'note event'
do
let_it_be
(
:issue_note
)
{
create
(
:note_on_issue
,
project:
project
,
note:
"issue note"
)
}
let_it_be
(
:issue_note
)
{
create
(
:note_on_issue
,
project:
project
,
note:
"issue note"
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Note
.
build
(
issue_note
,
user
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Note
.
build
(
issue_note
,
user
)
}
it
"calls
#{
service_name
}
API for note events"
do
it_behaves_like
'calls the service API with the event message'
,
/commented on issue/
execute_service
expect
(
WebMock
).
to
have_requested
(
:post
,
stubbed_resolved_hostname
).
once
end
context
'with event channel'
do
context
'with event channel'
do
let
(
:chat_service_params
)
{
{
note_channel:
'random'
}
}
let
(
:chat_service_params
)
{
{
note_channel:
'random'
}
}
...
...
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