Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e6880ebc
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,发现更多精彩内容 >>
提交
e6880ebc
编写于
8月 22, 2017
作者:
R
Rubén Dávila
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix inability to test some project integrations
上级
539ed0a6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
16 deletion
+40
-16
app/controllers/projects/services_controller.rb
app/controllers/projects/services_controller.rb
+3
-6
changelogs/unreleased/rd-fix-broken-configuration-for-some-integrations.yml
...sed/rd-fix-broken-configuration-for-some-integrations.yml
+5
-0
spec/controllers/projects/services_controller_spec.rb
spec/controllers/projects/services_controller_spec.rb
+32
-10
未找到文件。
app/controllers/projects/services_controller.rb
浏览文件 @
e6880ebc
...
...
@@ -4,7 +4,6 @@ class Projects::ServicesController < Projects::ApplicationController
# Authorize
before_action
:authorize_admin_project!
before_action
:service
,
only:
[
:edit
,
:update
,
:test
]
before_action
:update_service
,
only:
[
:update
,
:test
]
respond_to
:html
...
...
@@ -14,6 +13,8 @@ class Projects::ServicesController < Projects::ApplicationController
end
def
update
@service
.
attributes
=
service_params
[
:service
]
if
@service
.
save
(
context: :manual_change
)
redirect_to
(
project_settings_integrations_path
(
@project
),
notice:
success_message
)
else
...
...
@@ -24,7 +25,7 @@ class Projects::ServicesController < Projects::ApplicationController
def
test
message
=
{}
if
@service
.
can_test?
if
@service
.
can_test?
&&
@service
.
update_attributes
(
service_params
[
:service
])
data
=
@service
.
test_data
(
project
,
current_user
)
outcome
=
@service
.
test
(
data
)
...
...
@@ -50,10 +51,6 @@ class Projects::ServicesController < Projects::ApplicationController
end
end
def
update_service
@service
.
assign_attributes
(
service_params
[
:service
])
end
def
service
@service
||=
@project
.
find_or_initialize_service
(
params
[
:id
])
end
...
...
changelogs/unreleased/rd-fix-broken-configuration-for-some-integrations.yml
0 → 100644
浏览文件 @
e6880ebc
---
title
:
Testing of some integrations were broken due to missing ServiceHook record.
merge_request
:
author
:
type
:
fixed
spec/controllers/projects/services_controller_spec.rb
浏览文件 @
e6880ebc
...
...
@@ -10,9 +10,6 @@ describe Projects::ServicesController do
before
do
sign_in
(
user
)
project
.
team
<<
[
user
,
:master
]
controller
.
instance_variable_set
(
:@project
,
project
)
controller
.
instance_variable_set
(
:@service
,
service
)
end
describe
'#test'
do
...
...
@@ -20,7 +17,7 @@ describe Projects::ServicesController do
it
'renders 404'
do
allow_any_instance_of
(
Service
).
to
receive
(
:can_test?
).
and_return
(
false
)
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
expect
(
response
).
to
have_http_status
(
404
)
end
...
...
@@ -36,7 +33,7 @@ describe Projects::ServicesController do
it
'returns success'
do
allow_any_instance_of
(
MicrosoftTeams
::
Notifier
).
to
receive
(
:ping
).
and_return
(
true
)
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
expect
(
response
.
status
).
to
eq
(
200
)
end
...
...
@@ -45,7 +42,7 @@ describe Projects::ServicesController do
it
'returns success'
do
expect
(
HipChat
::
Client
).
to
receive
(
:new
).
with
(
'hipchat_token_p'
,
anything
).
and_return
(
hipchat_client
)
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
service_params
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
service_params
expect
(
response
.
status
).
to
eq
(
200
)
end
...
...
@@ -54,17 +51,42 @@ describe Projects::ServicesController do
it
'returns success'
do
expect
(
HipChat
::
Client
).
to
receive
(
:new
).
with
(
'hipchat_token_p'
,
anything
).
and_return
(
hipchat_client
)
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
service_params
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
service_params
expect
(
response
.
status
).
to
eq
(
200
)
end
context
'when service is configured for the first time'
do
before
do
allow_any_instance_of
(
ServiceHook
).
to
receive
(
:execute
).
and_return
(
true
)
end
it
'persist the object'
do
do_put
expect
(
BuildkiteService
.
first
).
to
be_present
end
it
'creates the ServiceHook object'
do
do_put
expect
(
BuildkiteService
.
first
.
service_hook
).
to
be_present
end
def
do_put
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
'buildkite'
,
service:
{
'active'
=>
'1'
,
'push_events'
=>
'1'
,
token:
'token'
,
'project_url'
=>
'http://test.com'
}
end
end
end
context
'failure'
do
it
'returns success status code and the error message'
do
expect
(
HipChat
::
Client
).
to
receive
(
:new
).
with
(
'hipchat_token_p'
,
anything
).
and_raise
(
'Bad test'
)
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
service_params
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
service_params
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
JSON
.
parse
(
response
.
body
))
...
...
@@ -77,7 +99,7 @@ describe Projects::ServicesController do
context
'when param `active` is set to true'
do
it
'activates the service and redirects to integrations paths'
do
put
:update
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
{
active:
true
}
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
{
active:
true
}
expect
(
response
).
to
redirect_to
(
project_settings_integrations_path
(
project
))
expect
(
flash
[
:notice
]).
to
eq
'HipChat activated.'
...
...
@@ -87,7 +109,7 @@ describe Projects::ServicesController do
context
'when param `active` is set to false'
do
it
'does not activate the service but saves the settings'
do
put
:update
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
{
active:
false
}
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
{
active:
false
}
expect
(
flash
[
:notice
]).
to
eq
'HipChat settings saved, but not activated.'
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录