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
3702fdde
Commit
3702fdde
authored
Jul 21, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Groups::HooksController#test implementation
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
80abdad6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
45 deletions
+7
-45
app/controllers/groups/hooks_controller.rb
app/controllers/groups/hooks_controller.rb
+6
-6
app/services/test_hook_service.rb
app/services/test_hook_service.rb
+0
-16
features/steps/group_hooks.rb
features/steps/group_hooks.rb
+1
-1
spec/services/test_hook_service_spec.rb
spec/services/test_hook_service_spec.rb
+0
-22
No files found.
app/controllers/groups/hooks_controller.rb
View file @
3702fdde
class
Groups::HooksController
<
Groups
::
ApplicationController
include
HooksExecution
# Authorize
before_action
:group
before_action
:authorize_admin_group!
...
...
@@ -27,13 +29,11 @@ class Groups::HooksController < Groups::ApplicationController
def
test
if
@group
.
first_non_empty_project
status
,
message
=
TestHookService
.
new
.
execute
(
hook
,
current_user
)
service
=
TestHooks
::
ProjectService
.
new
(
hook
,
current_user
,
'push_hooks'
)
service
.
project
=
@group
.
first_non_empty_project
result
=
service
.
execute
if
status
flash
[
:notice
]
=
'Hook successfully executed.'
else
flash
[
:alert
]
=
"Hook execution failed:
#{
message
}
"
end
set_hook_execution_notice
(
result
)
else
flash
[
:alert
]
=
'Hook execution failed. Ensure the group has a project with commits.'
end
...
...
app/services/test_hook_service.rb
deleted
100644 → 0
View file @
80abdad6
class
TestHookService
def
execute
(
hook
,
current_user
)
data
=
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
project
(
hook
),
current_user
)
hook
.
execute
(
data
,
'push_hooks'
)
end
private
def
project
(
hook
)
if
hook
.
is_a?
GroupHook
hook
.
group
.
first_non_empty_project
else
hook
.
project
end
end
end
features/steps/group_hooks.rb
View file @
3702fdde
...
...
@@ -55,7 +55,7 @@ class Spinach::Features::GroupHooks < Spinach::FeatureSteps
step
'hook should be triggered'
do
expect
(
current_path
).
to
eq
group_hooks_path
(
@group
)
expect
(
page
).
to
have_selector
'.flash-notice'
,
text:
'Hook
successfully executed.
'
text:
'Hook
executed successfully: HTTP 200
'
end
step
'I should see hook error message'
do
...
...
spec/services/test_hook_service_spec.rb
deleted
100644 → 0
View file @
80abdad6
require
'spec_helper'
describe
TestHookService
,
services:
true
do
let
(
:user
)
{
create
:user
}
let
(
:group
)
{
create
:group
}
let
(
:project
)
{
create
:project
,
:repository
,
group:
group
}
let
(
:project_hook
)
{
create
:project_hook
,
project:
project
}
let
(
:group_hook
)
{
create
:group_hook
,
group:
group
}
describe
'#execute'
do
it
"successfully executes the project hook"
do
stub_request
(
:post
,
project_hook
.
url
).
to_return
(
status:
200
)
expect
(
TestHookService
.
new
.
execute
(
project_hook
,
user
)).
to
be_truthy
end
it
"successfully executes the group hook"
do
project
.
reload
stub_request
(
:post
,
group_hook
.
url
).
to_return
(
status:
200
)
expect
(
TestHookService
.
new
.
execute
(
group_hook
,
user
)).
to
be_truthy
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