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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
21f10af0
Commit
21f10af0
authored
Aug 30, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scope hooks thal will run for confidential issues
parent
dd64f8aa
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
22 deletions
+55
-22
app/models/hooks/project_hook.rb
app/models/hooks/project_hook.rb
+1
-0
app/models/service.rb
app/models/service.rb
+1
-0
app/services/issues/base_service.rb
app/services/issues/base_service.rb
+4
-5
spec/services/issues/close_service_spec.rb
spec/services/issues/close_service_spec.rb
+12
-3
spec/services/issues/create_service_spec.rb
spec/services/issues/create_service_spec.rb
+12
-3
spec/services/issues/reopen_service_spec.rb
spec/services/issues/reopen_service_spec.rb
+22
-8
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+3
-3
No files found.
app/models/hooks/project_hook.rb
View file @
21f10af0
...
@@ -2,6 +2,7 @@ class ProjectHook < WebHook
...
@@ -2,6 +2,7 @@ class ProjectHook < WebHook
belongs_to
:project
belongs_to
:project
scope
:issue_hooks
,
->
{
where
(
issues_events:
true
)
}
scope
:issue_hooks
,
->
{
where
(
issues_events:
true
)
}
scope
:confidential_issue_hooks
,
->
{
where
(
confidential_issues_events:
true
)
}
scope
:note_hooks
,
->
{
where
(
note_events:
true
)
}
scope
:note_hooks
,
->
{
where
(
note_events:
true
)
}
scope
:merge_request_hooks
,
->
{
where
(
merge_requests_events:
true
)
}
scope
:merge_request_hooks
,
->
{
where
(
merge_requests_events:
true
)
}
scope
:build_hooks
,
->
{
where
(
build_events:
true
)
}
scope
:build_hooks
,
->
{
where
(
build_events:
true
)
}
...
...
app/models/service.rb
View file @
21f10af0
...
@@ -34,6 +34,7 @@ class Service < ActiveRecord::Base
...
@@ -34,6 +34,7 @@ class Service < ActiveRecord::Base
scope
:push_hooks
,
->
{
where
(
push_events:
true
,
active:
true
)
}
scope
:push_hooks
,
->
{
where
(
push_events:
true
,
active:
true
)
}
scope
:tag_push_hooks
,
->
{
where
(
tag_push_events:
true
,
active:
true
)
}
scope
:tag_push_hooks
,
->
{
where
(
tag_push_events:
true
,
active:
true
)
}
scope
:issue_hooks
,
->
{
where
(
issues_events:
true
,
active:
true
)
}
scope
:issue_hooks
,
->
{
where
(
issues_events:
true
,
active:
true
)
}
scope
:confidential_issue_hooks
,
->
{
where
(
confidential_issues_events:
true
,
active:
true
)
}
scope
:merge_request_hooks
,
->
{
where
(
merge_requests_events:
true
,
active:
true
)
}
scope
:merge_request_hooks
,
->
{
where
(
merge_requests_events:
true
,
active:
true
)
}
scope
:note_hooks
,
->
{
where
(
note_events:
true
,
active:
true
)
}
scope
:note_hooks
,
->
{
where
(
note_events:
true
,
active:
true
)
}
scope
:build_hooks
,
->
{
where
(
build_events:
true
,
active:
true
)
}
scope
:build_hooks
,
->
{
where
(
build_events:
true
,
active:
true
)
}
...
...
app/services/issues/base_service.rb
View file @
21f10af0
...
@@ -14,11 +14,10 @@ module Issues
...
@@ -14,11 +14,10 @@ module Issues
end
end
def
execute_hooks
(
issue
,
action
=
'open'
)
def
execute_hooks
(
issue
,
action
=
'open'
)
return
if
issue
.
confidential?
issue_data
=
hook_data
(
issue
,
action
)
issue_data
=
hook_data
(
issue
,
action
)
issue
.
project
.
execute_hooks
(
issue_data
,
:issue_hooks
)
hooks_scope
=
issue
.
confidential?
?
:confidential_issue_hooks
:
:issue_hooks
issue
.
project
.
execute_services
(
issue_data
,
:issue_hooks
)
issue
.
project
.
execute_hooks
(
issue_data
,
hooks_scope
)
issue
.
project
.
execute_services
(
issue_data
,
hooks_scope
)
end
end
end
end
end
end
spec/services/issues/close_service_spec.rb
View file @
21f10af0
...
@@ -53,12 +53,21 @@ describe Issues::CloseService, services: true do
...
@@ -53,12 +53,21 @@ describe Issues::CloseService, services: true do
end
end
end
end
context
'when issue is not confidential'
do
it
'executes issue hooks'
do
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
end
end
context
'when issue is confidential'
do
context
'when issue is confidential'
do
it
'
does not execut
e hooks'
do
it
'
executes confidential issu
e hooks'
do
issue
=
create
(
:issue
,
:confidential
,
project:
project
)
issue
=
create
(
:issue
,
:confidential
,
project:
project
)
expect
(
project
).
not_to
receive
(
:execut
e_hooks
)
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:confidential_issu
e_hooks
)
expect
(
project
).
not_to
receive
(
:execute_service
s
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:confidential_issue_hook
s
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
end
end
...
...
spec/services/issues/create_service_spec.rb
View file @
21f10af0
...
@@ -73,11 +73,20 @@ describe Issues::CreateService, services: true do
...
@@ -73,11 +73,20 @@ describe Issues::CreateService, services: true do
end
end
end
end
it
'does not execute hooks when issue is confidential'
do
it
'executes issue hooks when issue is not confidential'
do
opts
=
{
title:
'Title'
,
description:
'Description'
,
confidential:
false
}
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
described_class
.
new
(
project
,
user
,
opts
).
execute
end
it
'executes confidential issue hooks when issue is confidential'
do
opts
=
{
title:
'Title'
,
description:
'Description'
,
confidential:
true
}
opts
=
{
title:
'Title'
,
description:
'Description'
,
confidential:
true
}
expect
(
project
).
not_to
receive
(
:execut
e_hooks
)
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:confidential_issu
e_hooks
)
expect
(
project
).
not_to
receive
(
:execute_service
s
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:confidential_issue_hook
s
)
described_class
.
new
(
project
,
user
,
opts
).
execute
described_class
.
new
(
project
,
user
,
opts
).
execute
end
end
...
...
spec/services/issues/reopen_service_spec.rb
View file @
21f10af0
...
@@ -5,7 +5,7 @@ describe Issues::ReopenService, services: true do
...
@@ -5,7 +5,7 @@ describe Issues::ReopenService, services: true do
let
(
:issue
)
{
create
(
:issue
,
:closed
,
project:
project
)
}
let
(
:issue
)
{
create
(
:issue
,
:closed
,
project:
project
)
}
describe
'#execute'
do
describe
'#execute'
do
context
'
current
user is not authorized to reopen issue'
do
context
'
when
user is not authorized to reopen issue'
do
before
do
before
do
guest
=
create
(
:user
)
guest
=
create
(
:user
)
project
.
team
<<
[
guest
,
:guest
]
project
.
team
<<
[
guest
,
:guest
]
...
@@ -20,18 +20,32 @@ describe Issues::ReopenService, services: true do
...
@@ -20,18 +20,32 @@ describe Issues::ReopenService, services: true do
end
end
end
end
context
'when issue is confidential'
do
context
'when user is authrized to reopen issue'
do
it
'does not execute hooks'
do
let
(
:user
)
{
create
(
:user
)
}
user
=
create
(
:user
)
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user
,
:master
]
end
context
'when issue is not confidential'
do
it
'executes issue hooks'
do
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
end
end
context
'when issue is confidential'
do
it
'executes confidential issue hooks'
do
issue
=
create
(
:issue
,
:confidential
,
:closed
,
project:
project
)
issue
=
create
(
:issue
,
:confidential
,
:closed
,
project:
project
)
expect
(
project
).
not_to
receive
(
:execut
e_hooks
)
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:confidential_issu
e_hooks
)
expect
(
project
).
not_to
receive
(
:execute_service
s
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:confidential_issue_hook
s
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
end
end
end
end
end
end
end
end
end
spec/services/issues/update_service_spec.rb
View file @
21f10af0
...
@@ -105,9 +105,9 @@ describe Issues::UpdateService, services: true do
...
@@ -105,9 +105,9 @@ describe Issues::UpdateService, services: true do
expect
(
note
.
note
).
to
eq
'Made the issue confidential'
expect
(
note
.
note
).
to
eq
'Made the issue confidential'
end
end
it
'
does not execut
e hooks'
do
it
'
executes confidential issu
e hooks'
do
expect
(
project
).
not_to
receive
(
:execut
e_hooks
)
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:confidential_issu
e_hooks
)
expect
(
project
).
not_to
receive
(
:execute_service
s
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:confidential_issue_hook
s
)
update_issue
(
confidential:
true
)
update_issue
(
confidential:
true
)
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