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
8c21f24d
Commit
8c21f24d
authored
Jun 29, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove references to service in base chat notification spec
parent
3987e09a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
44 deletions
+44
-44
spec/models/integrations/base_chat_notification_spec.rb
spec/models/integrations/base_chat_notification_spec.rb
+44
-44
No files found.
spec/models/integrations/base_chat_notification_spec.rb
View file @
8c21f24d
...
@@ -34,7 +34,7 @@ RSpec.describe Integrations::BaseChatNotification do
...
@@ -34,7 +34,7 @@ RSpec.describe Integrations::BaseChatNotification do
end
end
describe
'#execute'
do
describe
'#execute'
do
subject
(
:chat_
service
)
{
described_class
.
new
}
subject
(
:chat_
integration
)
{
described_class
.
new
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
...
@@ -43,7 +43,7 @@ RSpec.describe Integrations::BaseChatNotification do
...
@@ -43,7 +43,7 @@ RSpec.describe Integrations::BaseChatNotification do
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
subject
.
project
,
user
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
subject
.
project
,
user
)
}
before
do
before
do
allow
(
chat_
service
).
to
receive_messages
(
allow
(
chat_
integration
).
to
receive_messages
(
project:
project
,
project:
project
,
project_id:
project
.
id
,
project_id:
project
.
id
,
service_hook:
true
,
service_hook:
true
,
...
@@ -57,8 +57,8 @@ RSpec.describe Integrations::BaseChatNotification do
...
@@ -57,8 +57,8 @@ RSpec.describe Integrations::BaseChatNotification do
context
'with a repository'
do
context
'with a repository'
do
it
'returns true'
do
it
'returns true'
do
expect
(
chat_
service
).
to
receive
(
:notify
).
and_return
(
true
)
expect
(
chat_
integration
).
to
receive
(
:notify
).
and_return
(
true
)
expect
(
chat_
service
.
execute
(
data
)).
to
be
true
expect
(
chat_
integration
.
execute
(
data
)).
to
be
true
end
end
end
end
...
@@ -66,8 +66,8 @@ RSpec.describe Integrations::BaseChatNotification do
...
@@ -66,8 +66,8 @@ RSpec.describe Integrations::BaseChatNotification do
it
'returns true'
do
it
'returns true'
do
subject
.
project
=
create
(
:project
,
:empty_repo
)
subject
.
project
=
create
(
:project
,
:empty_repo
)
expect
(
chat_
service
).
to
receive
(
:notify
).
and_return
(
true
)
expect
(
chat_
integration
).
to
receive
(
:notify
).
and_return
(
true
)
expect
(
chat_
service
.
execute
(
data
)).
to
be
true
expect
(
chat_
integration
.
execute
(
data
)).
to
be
true
end
end
end
end
...
@@ -75,8 +75,8 @@ RSpec.describe Integrations::BaseChatNotification do
...
@@ -75,8 +75,8 @@ RSpec.describe Integrations::BaseChatNotification do
it
'does not remove spaces'
do
it
'does not remove spaces'
do
allow
(
project
).
to
receive
(
:full_name
).
and_return
(
'Project Name'
)
allow
(
project
).
to
receive
(
:full_name
).
and_return
(
'Project Name'
)
expect
(
chat_
service
).
to
receive
(
:get_message
).
with
(
any_args
,
hash_including
(
project_name:
'Project Name'
))
expect
(
chat_
integration
).
to
receive
(
:get_message
).
with
(
any_args
,
hash_including
(
project_name:
'Project Name'
))
chat_
service
.
execute
(
data
)
chat_
integration
.
execute
(
data
)
end
end
end
end
...
@@ -89,76 +89,76 @@ RSpec.describe Integrations::BaseChatNotification do
...
@@ -89,76 +89,76 @@ RSpec.describe Integrations::BaseChatNotification do
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Note
.
build
(
note
,
user
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Note
.
build
(
note
,
user
)
}
shared_examples
'notifies the chat
service
'
do
shared_examples
'notifies the chat
integration
'
do
specify
do
specify
do
expect
(
chat_
service
).
to
receive
(
:notify
).
with
(
any_args
)
expect
(
chat_
integration
).
to
receive
(
:notify
).
with
(
any_args
)
chat_
service
.
execute
(
data
)
chat_
integration
.
execute
(
data
)
end
end
end
end
shared_examples
'does not notify the chat
service
'
do
shared_examples
'does not notify the chat
integration
'
do
specify
do
specify
do
expect
(
chat_
service
).
not_to
receive
(
:notify
).
with
(
any_args
)
expect
(
chat_
integration
).
not_to
receive
(
:notify
).
with
(
any_args
)
chat_
service
.
execute
(
data
)
chat_
integration
.
execute
(
data
)
end
end
end
end
it_behaves_like
'notifies the chat
service
'
it_behaves_like
'notifies the chat
integration
'
context
'with label filter'
do
context
'with label filter'
do
subject
(
:chat_
service
)
{
described_class
.
new
(
labels_to_be_notified:
'~Bug'
)
}
subject
(
:chat_
integration
)
{
described_class
.
new
(
labels_to_be_notified:
'~Bug'
)
}
it_behaves_like
'notifies the chat
service
'
it_behaves_like
'notifies the chat
integration
'
context
'MergeRequest events'
do
context
'MergeRequest events'
do
let
(
:data
)
{
create
(
:merge_request
,
labels:
[
label
]).
to_hook_data
(
user
)
}
let
(
:data
)
{
create
(
:merge_request
,
labels:
[
label
]).
to_hook_data
(
user
)
}
it_behaves_like
'notifies the chat
service
'
it_behaves_like
'notifies the chat
integration
'
end
end
context
'Issue events'
do
context
'Issue events'
do
let
(
:data
)
{
issue
.
to_hook_data
(
user
)
}
let
(
:data
)
{
issue
.
to_hook_data
(
user
)
}
it_behaves_like
'notifies the chat
service
'
it_behaves_like
'notifies the chat
integration
'
end
end
end
end
context
'when labels_to_be_notified_behavior is not defined'
do
context
'when labels_to_be_notified_behavior is not defined'
do
subject
(
:chat_
service
)
{
described_class
.
new
(
labels_to_be_notified:
label_filter
)
}
subject
(
:chat_
integration
)
{
described_class
.
new
(
labels_to_be_notified:
label_filter
)
}
context
'no matching labels'
do
context
'no matching labels'
do
let
(
:label_filter
)
{
'~some random label'
}
let
(
:label_filter
)
{
'~some random label'
}
it_behaves_like
'does not notify the chat
service
'
it_behaves_like
'does not notify the chat
integration
'
end
end
context
'only one label matches'
do
context
'only one label matches'
do
let
(
:label_filter
)
{
'~some random label, ~Bug'
}
let
(
:label_filter
)
{
'~some random label, ~Bug'
}
it_behaves_like
'notifies the chat
service
'
it_behaves_like
'notifies the chat
integration
'
end
end
end
end
context
'when labels_to_be_notified_behavior is blank'
do
context
'when labels_to_be_notified_behavior is blank'
do
subject
(
:chat_
service
)
{
described_class
.
new
(
labels_to_be_notified:
label_filter
,
labels_to_be_notified_behavior:
''
)
}
subject
(
:chat_
integration
)
{
described_class
.
new
(
labels_to_be_notified:
label_filter
,
labels_to_be_notified_behavior:
''
)
}
context
'no matching labels'
do
context
'no matching labels'
do
let
(
:label_filter
)
{
'~some random label'
}
let
(
:label_filter
)
{
'~some random label'
}
it_behaves_like
'does not notify the chat
service
'
it_behaves_like
'does not notify the chat
integration
'
end
end
context
'only one label matches'
do
context
'only one label matches'
do
let
(
:label_filter
)
{
'~some random label, ~Bug'
}
let
(
:label_filter
)
{
'~some random label, ~Bug'
}
it_behaves_like
'notifies the chat
service
'
it_behaves_like
'notifies the chat
integration
'
end
end
end
end
context
'when labels_to_be_notified_behavior is match_any'
do
context
'when labels_to_be_notified_behavior is match_any'
do
subject
(
:chat_
service
)
do
subject
(
:chat_
integration
)
do
described_class
.
new
(
described_class
.
new
(
labels_to_be_notified:
label_filter
,
labels_to_be_notified:
label_filter
,
labels_to_be_notified_behavior:
'match_any'
labels_to_be_notified_behavior:
'match_any'
...
@@ -168,24 +168,24 @@ RSpec.describe Integrations::BaseChatNotification do
...
@@ -168,24 +168,24 @@ RSpec.describe Integrations::BaseChatNotification do
context
'no label filter'
do
context
'no label filter'
do
let
(
:label_filter
)
{
nil
}
let
(
:label_filter
)
{
nil
}
it_behaves_like
'notifies the chat
service
'
it_behaves_like
'notifies the chat
integration
'
end
end
context
'no matching labels'
do
context
'no matching labels'
do
let
(
:label_filter
)
{
'~some random label'
}
let
(
:label_filter
)
{
'~some random label'
}
it_behaves_like
'does not notify the chat
service
'
it_behaves_like
'does not notify the chat
integration
'
end
end
context
'only one label matches'
do
context
'only one label matches'
do
let
(
:label_filter
)
{
'~some random label, ~Bug'
}
let
(
:label_filter
)
{
'~some random label, ~Bug'
}
it_behaves_like
'notifies the chat
service
'
it_behaves_like
'notifies the chat
integration
'
end
end
end
end
context
'when labels_to_be_notified_behavior is match_all'
do
context
'when labels_to_be_notified_behavior is match_all'
do
subject
(
:chat_
service
)
do
subject
(
:chat_
integration
)
do
described_class
.
new
(
described_class
.
new
(
labels_to_be_notified:
label_filter
,
labels_to_be_notified:
label_filter
,
labels_to_be_notified_behavior:
'match_all'
labels_to_be_notified_behavior:
'match_all'
...
@@ -195,31 +195,31 @@ RSpec.describe Integrations::BaseChatNotification do
...
@@ -195,31 +195,31 @@ RSpec.describe Integrations::BaseChatNotification do
context
'no label filter'
do
context
'no label filter'
do
let
(
:label_filter
)
{
nil
}
let
(
:label_filter
)
{
nil
}
it_behaves_like
'notifies the chat
service
'
it_behaves_like
'notifies the chat
integration
'
end
end
context
'no matching labels'
do
context
'no matching labels'
do
let
(
:label_filter
)
{
'~some random label'
}
let
(
:label_filter
)
{
'~some random label'
}
it_behaves_like
'does not notify the chat
service
'
it_behaves_like
'does not notify the chat
integration
'
end
end
context
'only one label matches'
do
context
'only one label matches'
do
let
(
:label_filter
)
{
'~some random label, ~Bug'
}
let
(
:label_filter
)
{
'~some random label, ~Bug'
}
it_behaves_like
'does not notify the chat
service
'
it_behaves_like
'does not notify the chat
integration
'
end
end
context
'labels matches exactly'
do
context
'labels matches exactly'
do
let
(
:label_filter
)
{
'~Bug, ~Backend, ~Community contribution'
}
let
(
:label_filter
)
{
'~Bug, ~Backend, ~Community contribution'
}
it_behaves_like
'notifies the chat
service
'
it_behaves_like
'notifies the chat
integration
'
end
end
context
'labels matches but object has more'
do
context
'labels matches but object has more'
do
let
(
:label_filter
)
{
'~Bug, ~Backend'
}
let
(
:label_filter
)
{
'~Bug, ~Backend'
}
it_behaves_like
'notifies the chat
service
'
it_behaves_like
'notifies the chat
integration
'
end
end
context
'labels are distributed on multiple objects'
do
context
'labels are distributed on multiple objects'
do
...
@@ -241,22 +241,22 @@ RSpec.describe Integrations::BaseChatNotification do
...
@@ -241,22 +241,22 @@ RSpec.describe Integrations::BaseChatNotification do
})
})
end
end
it_behaves_like
'does not notify the chat
service
'
it_behaves_like
'does not notify the chat
integration
'
end
end
end
end
end
end
context
'with "channel" property'
do
context
'with "channel" property'
do
before
do
before
do
allow
(
chat_
service
).
to
receive
(
:channel
).
and_return
(
channel
)
allow
(
chat_
integration
).
to
receive
(
:channel
).
and_return
(
channel
)
end
end
context
'empty string'
do
context
'empty string'
do
let
(
:channel
)
{
''
}
let
(
:channel
)
{
''
}
it
'does not include the channel'
do
it
'does not include the channel'
do
expect
(
chat_
service
).
to
receive
(
:notify
).
with
(
any_args
,
hash_excluding
(
:channel
)).
and_return
(
true
)
expect
(
chat_
integration
).
to
receive
(
:notify
).
with
(
any_args
,
hash_excluding
(
:channel
)).
and_return
(
true
)
expect
(
chat_
service
.
execute
(
data
)).
to
be
(
true
)
expect
(
chat_
integration
.
execute
(
data
)).
to
be
(
true
)
end
end
end
end
...
@@ -264,20 +264,20 @@ RSpec.describe Integrations::BaseChatNotification do
...
@@ -264,20 +264,20 @@ RSpec.describe Integrations::BaseChatNotification do
let
(
:channel
)
{
' '
}
let
(
:channel
)
{
' '
}
it
'does not include the channel'
do
it
'does not include the channel'
do
expect
(
chat_
service
).
to
receive
(
:notify
).
with
(
any_args
,
hash_excluding
(
:channel
)).
and_return
(
true
)
expect
(
chat_
integration
).
to
receive
(
:notify
).
with
(
any_args
,
hash_excluding
(
:channel
)).
and_return
(
true
)
expect
(
chat_
service
.
execute
(
data
)).
to
be
(
true
)
expect
(
chat_
integration
.
execute
(
data
)).
to
be
(
true
)
end
end
end
end
end
end
shared_examples
'with channel specified'
do
|
channel
,
expected_channels
|
shared_examples
'with channel specified'
do
|
channel
,
expected_channels
|
before
do
before
do
allow
(
chat_
service
).
to
receive
(
:push_channel
).
and_return
(
channel
)
allow
(
chat_
integration
).
to
receive
(
:push_channel
).
and_return
(
channel
)
end
end
it
'notifies all channels'
do
it
'notifies all channels'
do
expect
(
chat_
service
).
to
receive
(
:notify
).
with
(
any_args
,
hash_including
(
channel:
expected_channels
)).
and_return
(
true
)
expect
(
chat_
integration
).
to
receive
(
:notify
).
with
(
any_args
,
hash_including
(
channel:
expected_channels
)).
and_return
(
true
)
expect
(
chat_
service
.
execute
(
data
)).
to
be
(
true
)
expect
(
chat_
integration
.
execute
(
data
)).
to
be
(
true
)
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