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
Léo-Paul Géneau
gitlab-ce
Commits
d71d8ad7
Commit
d71d8ad7
authored
Sep 20, 2017
by
Alexis Reigel
Committed by
Alexis Reigel
Jan 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test hook for system merge request hook
parent
b22ae0c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
app/services/test_hooks/system_service.rb
app/services/test_hooks/system_service.rb
+7
-0
spec/services/test_hooks/system_service_spec.rb
spec/services/test_hooks/system_service_spec.rb
+20
-0
No files found.
app/services/test_hooks/system_service.rb
View file @
d71d8ad7
...
@@ -13,5 +13,12 @@ module TestHooks
...
@@ -13,5 +13,12 @@ module TestHooks
def
repository_update_events_data
def
repository_update_events_data
Gitlab
::
DataBuilder
::
Repository
.
sample_data
Gitlab
::
DataBuilder
::
Repository
.
sample_data
end
end
def
merge_requests_events_data
merge_request
=
MergeRequest
.
of_projects
(
current_user
.
projects
.
select
(
:id
)).
first
throw
(
:validation_error
,
'Ensure one of your projects has merge requests.'
)
unless
merge_request
.
present?
merge_request
.
to_hook_data
(
current_user
)
end
end
end
end
end
spec/services/test_hooks/system_service_spec.rb
View file @
d71d8ad7
...
@@ -60,5 +60,25 @@ describe TestHooks::SystemService do
...
@@ -60,5 +60,25 @@ describe TestHooks::SystemService do
expect
(
service
.
execute
).
to
include
(
success_result
)
expect
(
service
.
execute
).
to
include
(
success_result
)
end
end
end
end
context
'merge_requests_events'
do
let
(
:trigger
)
{
'merge_requests_events'
}
it
'returns error message if the user does not have any repository with a merge request'
do
expect
(
hook
).
not_to
receive
(
:execute
)
expect
(
service
.
execute
).
to
include
({
status: :error
,
message:
'Ensure one of your projects has merge requests.'
})
end
it
'executes hook'
do
trigger_key
=
:merge_request_hooks
sample_data
=
{
data:
'sample'
}
create
(
:project_member
,
user:
current_user
,
project:
project
)
create
(
:merge_request
,
source_project:
project
)
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:to_hook_data
).
and_return
(
sample_data
)
expect
(
hook
).
to
receive
(
:execute
).
with
(
sample_data
,
trigger_key
).
and_return
(
success_result
)
expect
(
service
.
execute
).
to
include
(
success_result
)
end
end
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