Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e11ee5ff
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 搜索 >>
提交
e11ee5ff
编写于
12月 23, 2015
作者:
J
Jacob Schatz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adds test for issue close/reopen failure
上级
b3e4bc59
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
63 addition
and
6 deletion
+63
-6
app/assets/javascripts/issue.js.coffee
app/assets/javascripts/issue.js.coffee
+3
-2
spec/javascripts/fixtures/issues_show.html.haml
spec/javascripts/fixtures/issues_show.html.haml
+11
-2
spec/javascripts/issue_spec.js.coffee
spec/javascripts/issue_spec.js.coffee
+49
-2
未找到文件。
app/assets/javascripts/issue.js.coffee
浏览文件 @
e11ee5ff
...
...
@@ -15,6 +15,7 @@ class @Issue
$
(
document
).
on
'tasklist:changed'
,
'.detail-page-description .js-task-list-container'
,
@
updateTaskList
initIssueBtnEventListeners
:
->
issueFailMessage
=
'Unable to update this issue at this time.'
$
(
'a.btn-close, a.btn-reopen'
).
on
'click'
,
(
e
)
->
e
.
preventDefault
()
e
.
stopImmediatePropagation
()
...
...
@@ -27,7 +28,7 @@ class @Issue
url
:
url
,
error
:
(
jqXHR
,
textStatus
,
errorThrown
)
->
issueStatus
=
if
isClose
then
'close'
else
'open'
new
Flash
(
'Issues update failed'
,
'alert'
)
new
Flash
(
issueFailMessage
,
'alert'
)
success
:
(
data
,
textStatus
,
jqXHR
)
->
if
data
.
saved
$this
.
addClass
(
'hidden'
)
...
...
@@ -40,7 +41,7 @@ class @Issue
$
(
'div.status-box-closed'
).
addClass
(
'hidden'
)
$
(
'div.status-box-open'
).
removeClass
(
'hidden'
)
else
new
Flash
(
'Issues update failed'
,
'alert'
)
new
Flash
(
issueFailMessage
,
'alert'
)
$this
.
prop
(
'disabled'
,
false
)
disableTaskList
:
->
...
...
spec/javascripts/fixtures/issues_show.html.haml
浏览文件 @
e11ee5ff
:css
.hidden
{
display
:
none
!important
;
}
.flash-container
-
if
alert
.flash-alert
=
alert
-
elsif
notice
.flash-notice
=
notice
.status-box.status-box-open
Open
.status-box.status-box-closed.hidden
Closed
%a
.btn-close
{
"href"
=>
"http://gitlab/issues/6/close"
}
Close
%a
.btn-reopen.hidden
{
"href"
=>
"http://gitlab/issues/6/reopen"
}
Reopen
%a
.btn-close
{
"href"
=>
"http://gitlab
.com
/issues/6/close"
}
Close
%a
.btn-reopen.hidden
{
"href"
=>
"http://gitlab
.com
/issues/6/reopen"
}
Reopen
.detail-page-description
.description.js-task-list-container
...
...
spec/javascripts/issue_spec.js.coffee
浏览文件 @
e11ee5ff
#= require flash
#= require issue
describe
'Issue'
,
->
...
...
@@ -28,7 +29,7 @@ describe 'reopen/close issue', ->
it
'closes an issue'
,
->
$
.
ajax
=
(
obj
)
->
expect
(
obj
.
type
).
toBe
(
'PUT'
)
expect
(
obj
.
url
).
toBe
(
'http://gitlab/issues/6/close'
)
expect
(
obj
.
url
).
toBe
(
'http://gitlab
.com
/issues/6/close'
)
obj
.
success
saved
:
true
$btnClose
=
$
(
'a.btn-close'
)
...
...
@@ -44,10 +45,56 @@ describe 'reopen/close issue', ->
expect
(
$
(
'div.status-box-closed'
)).
toBeVisible
()
expect
(
$
(
'div.status-box-open'
)).
toBeHidden
()
it
'fails to closes an issue with success:false'
,
->
$
.
ajax
=
(
obj
)
->
expect
(
obj
.
type
).
toBe
(
'PUT'
)
expect
(
obj
.
url
).
toBe
(
'http://goesnowhere.nothing/whereami'
)
obj
.
success
saved
:
false
$btnClose
=
$
(
'a.btn-close'
)
$btnReopen
=
$
(
'a.btn-reopen'
)
$btnClose
.
attr
(
'href'
,
'http://goesnowhere.nothing/whereami'
)
expect
(
$btnReopen
).
toBeHidden
()
expect
(
$btnClose
.
text
()).
toBe
(
'Close'
)
expect
(
typeof
$btnClose
.
prop
(
'disabled'
)).
toBe
(
'undefined'
)
$btnClose
.
trigger
(
'click'
)
expect
(
$btnReopen
).
toBeHidden
()
expect
(
$btnClose
).
toBeVisible
()
expect
(
$
(
'div.status-box-closed'
)).
toBeHidden
()
expect
(
$
(
'div.status-box-open'
)).
toBeVisible
()
expect
(
$
(
'div.flash-alert'
)).
toBeVisible
()
expect
(
$
(
'div.flash-alert'
).
text
()).
toBe
(
'Unable to update this issue at this time.'
)
it
'fails to closes an issue with HTTP error'
,
->
$
.
ajax
=
(
obj
)
->
expect
(
obj
.
type
).
toBe
(
'PUT'
)
expect
(
obj
.
url
).
toBe
(
'http://goesnowhere.nothing/whereami'
)
obj
.
error
()
$btnClose
=
$
(
'a.btn-close'
)
$btnReopen
=
$
(
'a.btn-reopen'
)
$btnClose
.
attr
(
'href'
,
'http://goesnowhere.nothing/whereami'
)
expect
(
$btnReopen
).
toBeHidden
()
expect
(
$btnClose
.
text
()).
toBe
(
'Close'
)
expect
(
typeof
$btnClose
.
prop
(
'disabled'
)).
toBe
(
'undefined'
)
$btnClose
.
trigger
(
'click'
)
expect
(
$btnReopen
).
toBeHidden
()
expect
(
$btnClose
).
toBeVisible
()
expect
(
$
(
'div.status-box-closed'
)).
toBeHidden
()
expect
(
$
(
'div.status-box-open'
)).
toBeVisible
()
expect
(
$
(
'div.flash-alert'
)).
toBeVisible
()
expect
(
$
(
'div.flash-alert'
).
text
()).
toBe
(
'Unable to update this issue at this time.'
)
it
'reopens an issue'
,
->
$
.
ajax
=
(
obj
)
->
expect
(
obj
.
type
).
toBe
(
'PUT'
)
expect
(
obj
.
url
).
toBe
(
'http://gitlab/issues/6/reopen'
)
expect
(
obj
.
url
).
toBe
(
'http://gitlab
.com
/issues/6/reopen'
)
obj
.
success
saved
:
true
$btnClose
=
$
(
'a.btn-close'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录