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
iv
gitlab-ce
Commits
7cefdb49
Commit
7cefdb49
authored
Jul 29, 2014
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent 500 if hook url is down, fixes #7376
parent
d30454e1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
2 deletions
+28
-2
app/controllers/projects/hooks_controller.rb
app/controllers/projects/hooks_controller.rb
+7
-2
app/services/test_hook_service.rb
app/services/test_hook_service.rb
+3
-0
features/project/hooks.feature
features/project/hooks.feature
+6
-0
features/steps/project/hooks.rb
features/steps/project/hooks.rb
+12
-0
No files found.
app/controllers/projects/hooks_controller.rb
View file @
7cefdb49
...
@@ -25,8 +25,13 @@ class Projects::HooksController < Projects::ApplicationController
...
@@ -25,8 +25,13 @@ class Projects::HooksController < Projects::ApplicationController
def
test
def
test
if
!
@project
.
empty_repo?
if
!
@project
.
empty_repo?
TestHookService
.
new
.
execute
(
hook
,
current_user
)
status
=
TestHookService
.
new
.
execute
(
hook
,
current_user
)
if
status
flash
[
:notice
]
=
'Hook successfully executed.'
flash
[
:notice
]
=
'Hook successfully executed.'
else
flash
[
:alert
]
=
'Hook execution failed. '
\
'Ensure hook URL is correct and service is up.'
end
else
else
flash
[
:alert
]
=
'Hook execution failed. Ensure the project has commits.'
flash
[
:alert
]
=
'Hook execution failed. Ensure the project has commits.'
end
end
...
...
app/services/test_hook_service.rb
View file @
7cefdb49
...
@@ -2,5 +2,8 @@ class TestHookService
...
@@ -2,5 +2,8 @@ class TestHookService
def
execute
(
hook
,
current_user
)
def
execute
(
hook
,
current_user
)
data
=
GitPushService
.
new
.
sample_data
(
hook
.
project
,
current_user
)
data
=
GitPushService
.
new
.
sample_data
(
hook
.
project
,
current_user
)
hook
.
execute
(
data
)
hook
.
execute
(
data
)
true
rescue
SocketError
false
end
end
end
end
features/project/hooks.feature
View file @
7cefdb49
...
@@ -24,3 +24,9 @@ Feature: Project Hooks
...
@@ -24,3 +24,9 @@ Feature: Project Hooks
And
I visit project hooks page
And
I visit project hooks page
When
I click test hook button
When
I click test hook button
Then
I should see hook error message
Then
I should see hook error message
Scenario
:
I
test a hook on down URL
Given
project has hook
And
I visit project hooks page
When
I click test hook button with invalid URL
Then
I should see hook service down error message
features/steps/project/hooks.rb
View file @
7cefdb49
...
@@ -38,6 +38,11 @@ class ProjectHooks < Spinach::FeatureSteps
...
@@ -38,6 +38,11 @@ class ProjectHooks < Spinach::FeatureSteps
click_link
'Test Hook'
click_link
'Test Hook'
end
end
step
'I click test hook button with invalid URL'
do
stub_request
(
:post
,
@hook
.
url
).
to_raise
(
SocketError
)
click_link
'Test Hook'
end
step
'hook should be triggered'
do
step
'hook should be triggered'
do
page
.
current_path
.
should
==
project_hooks_path
(
current_project
)
page
.
current_path
.
should
==
project_hooks_path
(
current_project
)
page
.
should
have_selector
'.flash-notice'
,
page
.
should
have_selector
'.flash-notice'
,
...
@@ -49,4 +54,11 @@ class ProjectHooks < Spinach::FeatureSteps
...
@@ -49,4 +54,11 @@ class ProjectHooks < Spinach::FeatureSteps
text:
'Hook execution failed. '
\
text:
'Hook execution failed. '
\
'Ensure the project has commits.'
'Ensure the project has commits.'
end
end
step
'I should see hook service down error message'
do
page
.
should
have_selector
'.flash-alert'
,
text:
'Hook execution failed. '
\
'Ensure hook URL is correct and '
\
'service is up.'
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