BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e11ee5ff
Commit
e11ee5ff
authored
Dec 23, 2015
by
Jacob Schatz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds test for issue close/reopen failure
parent
b3e4bc59
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
6 deletions
+63
-6
issue.js.coffee
app/assets/javascripts/issue.js.coffee
+3
-2
issues_show.html.haml
spec/javascripts/fixtures/issues_show.html.haml
+11
-2
issue_spec.js.coffee
spec/javascripts/issue_spec.js.coffee
+49
-2
No files found.
app/assets/javascripts/issue.js.coffee
View file @
e11ee5ff
...
@@ -15,6 +15,7 @@ class @Issue
...
@@ -15,6 +15,7 @@ class @Issue
$
(
document
).
on
'tasklist:changed'
,
'.detail-page-description .js-task-list-container'
,
@
updateTaskList
$
(
document
).
on
'tasklist:changed'
,
'.detail-page-description .js-task-list-container'
,
@
updateTaskList
initIssueBtnEventListeners
:
->
initIssueBtnEventListeners
:
->
issueFailMessage
=
'Unable to update this issue at this time.'
$
(
'a.btn-close, a.btn-reopen'
).
on
'click'
,
(
e
)
->
$
(
'a.btn-close, a.btn-reopen'
).
on
'click'
,
(
e
)
->
e
.
preventDefault
()
e
.
preventDefault
()
e
.
stopImmediatePropagation
()
e
.
stopImmediatePropagation
()
...
@@ -27,7 +28,7 @@ class @Issue
...
@@ -27,7 +28,7 @@ class @Issue
url
:
url
,
url
:
url
,
error
:
(
jqXHR
,
textStatus
,
errorThrown
)
->
error
:
(
jqXHR
,
textStatus
,
errorThrown
)
->
issueStatus
=
if
isClose
then
'close'
else
'open'
issueStatus
=
if
isClose
then
'close'
else
'open'
new
Flash
(
'Issues update failed'
,
'alert'
)
new
Flash
(
issueFailMessage
,
'alert'
)
success
:
(
data
,
textStatus
,
jqXHR
)
->
success
:
(
data
,
textStatus
,
jqXHR
)
->
if
data
.
saved
if
data
.
saved
$this
.
addClass
(
'hidden'
)
$this
.
addClass
(
'hidden'
)
...
@@ -40,7 +41,7 @@ class @Issue
...
@@ -40,7 +41,7 @@ class @Issue
$
(
'div.status-box-closed'
).
addClass
(
'hidden'
)
$
(
'div.status-box-closed'
).
addClass
(
'hidden'
)
$
(
'div.status-box-open'
).
removeClass
(
'hidden'
)
$
(
'div.status-box-open'
).
removeClass
(
'hidden'
)
else
else
new
Flash
(
'Issues update failed'
,
'alert'
)
new
Flash
(
issueFailMessage
,
'alert'
)
$this
.
prop
(
'disabled'
,
false
)
$this
.
prop
(
'disabled'
,
false
)
disableTaskList
:
->
disableTaskList
:
->
...
...
spec/javascripts/fixtures/issues_show.html.haml
View file @
e11ee5ff
:css
:css
.hidden
{
display
:
none
!important
;
}
.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-open
Open
.status-box.status-box-closed.hidden
Closed
.status-box.status-box-closed.hidden
Closed
%a
.btn-close
{
"href"
=>
"http://gitlab/issues/6/close"
}
Close
%a
.btn-close
{
"href"
=>
"http://gitlab
.com
/issues/6/close"
}
Close
%a
.btn-reopen.hidden
{
"href"
=>
"http://gitlab/issues/6/reopen"
}
Reopen
%a
.btn-reopen.hidden
{
"href"
=>
"http://gitlab
.com
/issues/6/reopen"
}
Reopen
.detail-page-description
.detail-page-description
.description.js-task-list-container
.description.js-task-list-container
...
...
spec/javascripts/issue_spec.js.coffee
View file @
e11ee5ff
#= require flash
#= require issue
#= require issue
describe
'Issue'
,
->
describe
'Issue'
,
->
...
@@ -28,7 +29,7 @@ describe 'reopen/close issue', ->
...
@@ -28,7 +29,7 @@ describe 'reopen/close issue', ->
it
'closes an issue'
,
->
it
'closes an issue'
,
->
$
.
ajax
=
(
obj
)
->
$
.
ajax
=
(
obj
)
->
expect
(
obj
.
type
).
toBe
(
'PUT'
)
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
obj
.
success
saved
:
true
$btnClose
=
$
(
'a.btn-close'
)
$btnClose
=
$
(
'a.btn-close'
)
...
@@ -44,10 +45,56 @@ describe 'reopen/close issue', ->
...
@@ -44,10 +45,56 @@ describe 'reopen/close issue', ->
expect
(
$
(
'div.status-box-closed'
)).
toBeVisible
()
expect
(
$
(
'div.status-box-closed'
)).
toBeVisible
()
expect
(
$
(
'div.status-box-open'
)).
toBeHidden
()
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'
,
->
it
'reopens an issue'
,
->
$
.
ajax
=
(
obj
)
->
$
.
ajax
=
(
obj
)
->
expect
(
obj
.
type
).
toBe
(
'PUT'
)
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
obj
.
success
saved
:
true
$btnClose
=
$
(
'a.btn-close'
)
$btnClose
=
$
(
'a.btn-close'
)
...
...
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