Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
7122a823
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7122a823
编写于
8月 11, 2014
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7393 from Razer6/fix_500_hook_service_down
Prevent 500 if hook url is down when testing a hook, fixes #7376
上级
42d4ed3a
7cefdb49
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
2 deletion
+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
未找到文件。
app/controllers/projects/hooks_controller.rb
浏览文件 @
7122a823
...
...
@@ -25,8 +25,13 @@ class Projects::HooksController < Projects::ApplicationController
def
test
if
!
@project
.
empty_repo?
TestHookService
.
new
.
execute
(
hook
,
current_user
)
flash
[
:notice
]
=
'Hook successfully executed.'
status
=
TestHookService
.
new
.
execute
(
hook
,
current_user
)
if
status
flash
[
:notice
]
=
'Hook successfully executed.'
else
flash
[
:alert
]
=
'Hook execution failed. '
\
'Ensure hook URL is correct and service is up.'
end
else
flash
[
:alert
]
=
'Hook execution failed. Ensure the project has commits.'
end
...
...
app/services/test_hook_service.rb
浏览文件 @
7122a823
...
...
@@ -2,5 +2,8 @@ class TestHookService
def
execute
(
hook
,
current_user
)
data
=
GitPushService
.
new
.
sample_data
(
hook
.
project
,
current_user
)
hook
.
execute
(
data
)
true
rescue
SocketError
false
end
end
features/project/hooks.feature
浏览文件 @
7122a823
...
...
@@ -24,3 +24,9 @@ Feature: Project Hooks
And
I visit project hooks page
When
I click test hook button
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
浏览文件 @
7122a823
...
...
@@ -38,6 +38,11 @@ class ProjectHooks < Spinach::FeatureSteps
click_link
'Test Hook'
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
page
.
current_path
.
should
==
project_hooks_path
(
current_project
)
page
.
should
have_selector
'.flash-notice'
,
...
...
@@ -49,4 +54,11 @@ class ProjectHooks < Spinach::FeatureSteps
text:
'Hook execution failed. '
\
'Ensure the project has commits.'
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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录