Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
aa2b3ff1
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,体验更适合开发者的 AI 搜索 >>
提交
aa2b3ff1
编写于
7月 26, 2017
作者:
J
Jarka Kadlecova
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Display specific error message when JIRA test fails
上级
f2da36f1
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
38 addition
and
13 deletion
+38
-13
app/assets/javascripts/integrations/integration_settings_form.js
...ets/javascripts/integrations/integration_settings_form.js
+1
-1
app/models/project_services/jira_service.rb
app/models/project_services/jira_service.rb
+6
-2
changelogs/unreleased/32483-jira-error.yml
changelogs/unreleased/32483-jira-error.yml
+4
-0
spec/features/projects/services/jira_service_spec.rb
spec/features/projects/services/jira_service_spec.rb
+1
-1
spec/javascripts/integrations/integration_settings_form_spec.js
...avascripts/integrations/integration_settings_form_spec.js
+2
-2
spec/models/project_services/jira_service_spec.rb
spec/models/project_services/jira_service_spec.rb
+24
-7
未找到文件。
app/assets/javascripts/integrations/integration_settings_form.js
浏览文件 @
aa2b3ff1
...
@@ -102,7 +102,7 @@ export default class IntegrationSettingsForm {
...
@@ -102,7 +102,7 @@ export default class IntegrationSettingsForm {
})
})
.
done
((
res
)
=>
{
.
done
((
res
)
=>
{
if
(
res
.
error
)
{
if
(
res
.
error
)
{
new
Flash
(
res
.
message
,
null
,
null
,
{
new
Flash
(
`
${
res
.
message
}
${
res
.
service_response
}
`
,
null
,
null
,
{
title
:
'
Save anyway
'
,
title
:
'
Save anyway
'
,
clickHandler
:
(
e
)
=>
{
clickHandler
:
(
e
)
=>
{
e
.
preventDefault
();
e
.
preventDefault
();
...
...
app/models/project_services/jira_service.rb
浏览文件 @
aa2b3ff1
...
@@ -160,7 +160,10 @@ class JiraService < IssueTrackerService
...
@@ -160,7 +160,10 @@ class JiraService < IssueTrackerService
def
test
(
_
)
def
test
(
_
)
result
=
test_settings
result
=
test_settings
{
success:
result
.
present?
,
result:
result
}
success
=
result
.
present?
result
=
@error
if
@error
&&
!
success
{
success:
success
,
result:
result
}
end
end
# JIRA does not need test data.
# JIRA does not need test data.
...
@@ -288,7 +291,8 @@ class JiraService < IssueTrackerService
...
@@ -288,7 +291,8 @@ class JiraService < IssueTrackerService
yield
yield
rescue
Timeout
::
Error
,
Errno
::
EINVAL
,
Errno
::
ECONNRESET
,
Errno
::
ECONNREFUSED
,
URI
::
InvalidURIError
,
JIRA
::
HTTPError
,
OpenSSL
::
SSL
::
SSLError
=>
e
rescue
Timeout
::
Error
,
Errno
::
EINVAL
,
Errno
::
ECONNRESET
,
Errno
::
ECONNREFUSED
,
URI
::
InvalidURIError
,
JIRA
::
HTTPError
,
OpenSSL
::
SSL
::
SSLError
=>
e
Rails
.
logger
.
info
"
#{
self
.
class
.
name
}
Send message ERROR:
#{
client_url
}
-
#{
e
.
message
}
"
@error
=
e
.
message
Rails
.
logger
.
info
"
#{
self
.
class
.
name
}
Send message ERROR:
#{
client_url
}
-
#{
@error
}
"
nil
nil
end
end
...
...
changelogs/unreleased/32483-jira-error.yml
0 → 100644
浏览文件 @
aa2b3ff1
---
title
:
Display specific error message when JIRA test fails
merge_request
:
author
:
spec/features/projects/services/jira_service_spec.rb
浏览文件 @
aa2b3ff1
...
@@ -62,7 +62,7 @@ feature 'Setup Jira service', :feature, :js do
...
@@ -62,7 +62,7 @@ feature 'Setup Jira service', :feature, :js do
click_button
(
'Test settings and save changes'
)
click_button
(
'Test settings and save changes'
)
wait_for_requests
wait_for_requests
expect
(
find
(
'.flash-container-page'
)).
to
have_content
'Test failed.'
expect
(
find
(
'.flash-container-page'
)).
to
have_content
'Test failed.
message
'
expect
(
find
(
'.flash-container-page'
)).
to
have_content
'Save anyway'
expect
(
find
(
'.flash-container-page'
)).
to
have_content
'Save anyway'
find
(
'.flash-alert .flash-action'
).
trigger
(
'click'
)
find
(
'.flash-alert .flash-action'
).
trigger
(
'click'
)
...
...
spec/javascripts/integrations/integration_settings_form_spec.js
浏览文件 @
aa2b3ff1
...
@@ -135,10 +135,10 @@ describe('IntegrationSettingsForm', () => {
...
@@ -135,10 +135,10 @@ describe('IntegrationSettingsForm', () => {
integrationSettingsForm
.
testSettings
(
formData
);
integrationSettingsForm
.
testSettings
(
formData
);
deferred
.
resolve
({
error
:
true
,
message
:
errorMessage
});
deferred
.
resolve
({
error
:
true
,
message
:
errorMessage
,
service_response
:
'
some error
'
});
const
$flashContainer
=
$
(
'
.flash-container
'
);
const
$flashContainer
=
$
(
'
.flash-container
'
);
expect
(
$flashContainer
.
find
(
'
.flash-text
'
).
text
()).
toEqual
(
errorMessage
);
expect
(
$flashContainer
.
find
(
'
.flash-text
'
).
text
()).
toEqual
(
'
Test failed. some error
'
);
expect
(
$flashContainer
.
find
(
'
.flash-action
'
)).
toBeDefined
();
expect
(
$flashContainer
.
find
(
'
.flash-action
'
)).
toBeDefined
();
expect
(
$flashContainer
.
find
(
'
.flash-action
'
).
text
()).
toEqual
(
'
Save anyway
'
);
expect
(
$flashContainer
.
find
(
'
.flash-action
'
).
text
()).
toEqual
(
'
Save anyway
'
);
});
});
...
...
spec/models/project_services/jira_service_spec.rb
浏览文件 @
aa2b3ff1
...
@@ -197,24 +197,41 @@ describe JiraService, models: true do
...
@@ -197,24 +197,41 @@ describe JiraService, models: true do
)
)
end
end
def
test_settings
(
api_url
)
def
test_settings
(
api_url
=
nil
)
api_url
||=
'jira.example.com'
test_url
=
"http://
#{
api_url
}
/rest/api/2/serverInfo"
test_url
=
"http://
#{
api_url
}
/rest/api/2/serverInfo"
WebMock
.
stub_request
(
:get
,
test_url
).
with
(
basic_auth:
%w(jira_username jira_password)
).
to_return
(
body:
{
url:
'http://url'
}.
to_json
)
WebMock
.
stub_request
(
:get
,
test_url
).
with
(
basic_auth:
%w(jira_username jira_password)
).
to_return
(
body:
{
url:
'http://url'
}.
to_json
)
jira_service
.
test
_settings
jira_service
.
test
(
nil
)
end
end
context
'when the test succeeds'
do
it
'tries to get JIRA project with URL when API URL not set'
do
it
'tries to get JIRA project with URL when API URL not set'
do
test_settings
(
'jira.example.com'
)
test_settings
(
'jira.example.com'
)
end
end
it
'returns correct result'
do
expect
(
test_settings
).
to
eq
(
{
success:
true
,
result:
{
'url'
=>
'http://url'
}
})
end
it
'tries to get JIRA project with API URL if set'
do
it
'tries to get JIRA project with API URL if set'
do
jira_service
.
update
(
api_url:
'http://jira.api.com'
)
jira_service
.
update
(
api_url:
'http://jira.api.com'
)
test_settings
(
'jira.api.com'
)
test_settings
(
'jira.api.com'
)
end
end
end
end
context
'when the test fails'
do
it
'returns result with the error'
do
test_url
=
'http://jira.example.com/rest/api/2/serverInfo'
WebMock
.
stub_request
(
:get
,
test_url
).
with
(
basic_auth:
%w(jira_username jira_password)
)
.
to_raise
(
JIRA
::
HTTPError
.
new
(
double
(
message:
'Some specific failure.'
)))
expect
(
jira_service
.
test
(
nil
)).
to
eq
(
{
success:
false
,
result:
'Some specific failure.'
})
end
end
end
describe
"Stored password invalidation"
do
describe
"Stored password invalidation"
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录