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
5a88372c
Commit
5a88372c
authored
Dec 15, 2020
by
serenafang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add group spec
Group spec not fully working
parent
c3f0b8a0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
3 deletions
+36
-3
ee/app/models/ee/group.rb
ee/app/models/ee/group.rb
+2
-0
ee/spec/models/group_member_spec.rb
ee/spec/models/group_member_spec.rb
+3
-3
ee/spec/models/group_spec.rb
ee/spec/models/group_spec.rb
+31
-0
No files found.
ee/app/models/ee/group.rb
View file @
5a88372c
...
...
@@ -452,6 +452,8 @@ module EE
def
execute_hooks
(
data
,
hooks_scope
)
super
return
unless
feature_available?
(
:group_webhooks
)
self_and_ancestor_hooks
=
GroupHook
.
where
(
group_id:
self
.
self_and_ancestors
)
self_and_ancestor_hooks
.
hooks_for
(
hooks_scope
).
each
do
|
hook
|
hook
.
async_execute
(
data
,
hooks_scope
.
to_s
)
...
...
ee/spec/models/group_member_spec.rb
View file @
5a88372c
...
...
@@ -249,13 +249,13 @@ RSpec.describe GroupMember do
end
it
'execute webhooks'
do
group
.
add_guest
(
user
)
member
=
group
.
add_guest
(
user
)
expect
(
WebMock
).
to
have_requested
(
:post
,
group_hook
.
url
).
with
(
headers:
{
'Content-Type'
=>
'application/json'
,
'User-Agent'
=>
"GitLab/
#{
Gitlab
::
VERSION
}
"
,
'X-Gitlab-Event'
=>
'Member Hook'
},
body:
{
created_at:
us
er
.
created_at
&
.
xmlschema
,
updated_at:
us
er
.
updated_at
&
.
xmlschema
,
created_at:
memb
er
.
created_at
&
.
xmlschema
,
updated_at:
memb
er
.
updated_at
&
.
xmlschema
,
group_name:
group
.
name
,
group_path:
group
.
path
,
group_id:
group
.
id
,
...
...
ee/spec/models/group_spec.rb
View file @
5a88372c
...
...
@@ -898,6 +898,37 @@ RSpec.describe Group do
end
end
describe
"#execute_hooks"
do
context
"group_webhooks"
,
:sidekiq_inline
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:group_hook
)
{
create
(
:group_hook
,
group:
group
,
member_events:
true
)
}
let
(
:data
)
{
{
some:
'info'
}
}
context
'when group_webhooks feature is enabled'
do
before
do
stub_licensed_features
(
group_webhooks:
true
)
end
let
(
:service
)
{
double
}
it
'executes the hook'
do
expect
(
service
).
to
receive
(
:async_execute
).
once
expect
(
WebHookService
).
to
receive
(
:new
)
group
.
execute_hooks
(
data
,
:member_hooks
)
end
end
it
'does not execute the hook when the feature is disabled'
do
stub_licensed_features
(
group_webhooks:
false
)
expect
(
WebHookService
).
not_to
receive
(
:new
)
group
.
execute_hooks
(
data
,
:member_hooks
)
end
end
end
describe
'#self_or_ancestor_marked_for_deletion'
do
context
'delayed deletion feature is not available'
do
before
do
...
...
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