Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8afc2873
Commit
8afc2873
authored
Aug 27, 2016
by
winniehell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up issue_spec.js
parent
4370d68f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
59 deletions
+102
-59
spec/javascripts/issue_spec.js
spec/javascripts/issue_spec.js
+102
-59
No files found.
spec/javascripts/issue_spec.js
View file @
8afc2873
...
@@ -4,6 +4,56 @@
...
@@ -4,6 +4,56 @@
/*= require issue */
/*= require issue */
(
function
()
{
(
function
()
{
var
INVALID_URL
=
'
http://goesnowhere.nothing/whereami
'
;
var
$boxClosed
,
$boxOpen
,
$btnClose
,
$btnReopen
;
function
expectErrorMessage
()
{
var
$flashMessage
=
$
(
'
div.flash-alert
'
);
expect
(
$flashMessage
).
toExist
();
expect
(
$flashMessage
).
toBeVisible
();
expect
(
$flashMessage
).
toHaveText
(
'
Unable to update this issue at this time.
'
);
}
function
expectIssueState
(
isIssueOpen
)
{
expectVisibility
(
$boxClosed
,
!
isIssueOpen
);
expectVisibility
(
$boxOpen
,
isIssueOpen
);
expectVisibility
(
$btnClose
,
isIssueOpen
);
expectVisibility
(
$btnReopen
,
!
isIssueOpen
);
}
function
expectPendingRequest
(
req
,
$triggeredButton
)
{
expect
(
req
.
type
).
toBe
(
'
PUT
'
);
expect
(
req
.
url
).
toBe
(
$triggeredButton
.
attr
(
'
href
'
));
expect
(
$triggeredButton
).
toHaveProp
(
'
disabled
'
,
true
);
}
function
expectVisibility
(
$element
,
shouldBeVisible
)
{
if
(
shouldBeVisible
)
{
expect
(
$element
).
not
.
toHaveClass
(
'
hidden
'
);
}
else
{
expect
(
$element
).
toHaveClass
(
'
hidden
'
);
}
}
function
findElements
()
{
$boxClosed
=
$
(
'
div.status-box-closed
'
);
expect
(
$boxClosed
).
toExist
();
expect
(
$boxClosed
).
toHaveText
(
'
Closed
'
);
$boxOpen
=
$
(
'
div.status-box-open
'
);
expect
(
$boxOpen
).
toExist
();
expect
(
$boxOpen
).
toHaveText
(
'
Open
'
);
$btnClose
=
$
(
'
.btn-close.btn-grouped
'
);
expect
(
$btnClose
).
toExist
();
expect
(
$btnClose
).
toHaveText
(
'
Close issue
'
);
$btnReopen
=
$
(
'
.btn-reopen.btn-grouped
'
);
expect
(
$btnReopen
).
toExist
();
expect
(
$btnReopen
).
toHaveText
(
'
Reopen issue
'
);
}
describe
(
'
Issue
'
,
function
()
{
describe
(
'
Issue
'
,
function
()
{
return
describe
(
'
task lists
'
,
function
()
{
return
describe
(
'
task lists
'
,
function
()
{
fixture
.
preload
(
'
issues_show.html
'
);
fixture
.
preload
(
'
issues_show.html
'
);
...
@@ -27,93 +77,86 @@
...
@@ -27,93 +77,86 @@
});
});
});
});
describe
(
'
reopen/
close issue
'
,
function
()
{
describe
(
'
close issue
'
,
function
()
{
fixture
.
preload
(
'
issues_show.html
'
);
fixture
.
preload
(
'
issues_show.html
'
);
beforeEach
(
function
()
{
beforeEach
(
function
()
{
fixture
.
load
(
'
issues_show.html
'
);
fixture
.
load
(
'
issues_show.html
'
);
return
this
.
issue
=
new
Issue
();
findElements
();
this
.
issue
=
new
Issue
();
expectIssueState
(
true
);
});
});
it
(
'
closes an issue
'
,
function
()
{
it
(
'
closes an issue
'
,
function
()
{
var
$btnClose
,
$btnReopen
;
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
expect
(
req
.
type
).
toBe
(
'
PUT
'
);
expectPendingRequest
(
req
,
$btnClose
);
expect
(
req
.
url
).
toBe
(
'
http://gitlab.com/issues/6/close
'
);
req
.
success
({
return
req
.
success
({
id
:
34
id
:
34
});
});
});
});
$btnClose
=
$
(
'
a.btn-close
'
);
$btnReopen
=
$
(
'
a.btn-reopen
'
);
expect
(
$btnReopen
).
toBeHidden
();
expect
(
$btnClose
.
text
()).
toBe
(
'
Close
'
);
expect
(
typeof
$btnClose
.
prop
(
'
disabled
'
)).
toBe
(
'
undefined
'
);
$btnClose
.
trigger
(
'
click
'
);
$btnClose
.
trigger
(
'
click
'
);
expect
(
$btnReopen
).
toBeVisible
();
expect
(
$btnClose
).
toBeHidden
();
expectIssueState
(
false
);
expect
(
$
(
'
div.status-box-closed
'
)).
toBeVisible
();
expect
(
$btnClose
).
toHaveProp
(
'
disabled
'
,
false
);
return
expect
(
$
(
'
div.status-box-open
'
)).
toBeHidden
();
});
});
it
(
'
fails to close an issue with success:false
'
,
function
()
{
it
(
'
fails to close an issue with success:false
'
,
function
()
{
var
$btnClose
,
$btnReopen
;
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
expect
(
req
.
type
).
toBe
(
'
PUT
'
);
expectPendingRequest
(
req
,
$btnClose
);
expect
(
req
.
url
).
toBe
(
'
http://goesnowhere.nothing/whereami
'
);
req
.
success
({
return
req
.
success
({
saved
:
false
saved
:
false
});
});
});
});
$btnClose
=
$
(
'
a.btn-close
'
);
$btnReopen
=
$
(
'
a.btn-reopen
'
);
$btnClose
.
attr
(
'
href
'
,
INVALID_URL
);
$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
'
);
$btnClose
.
trigger
(
'
click
'
);
expect
(
$btnReopen
).
toBeHidden
();
expect
(
$btnClose
).
toBeVisible
();
expectIssueState
(
true
);
expect
(
$
(
'
div.status-box-closed
'
)).
toBeHidden
();
expect
(
$btnClose
).
toHaveProp
(
'
disabled
'
,
false
);
expect
(
$
(
'
div.status-box-open
'
)).
toBeVisible
();
expectErrorMessage
();
expect
(
$
(
'
div.flash-alert
'
)).
toBeVisible
();
return
expect
(
$
(
'
div.flash-alert
'
).
text
()).
toBe
(
'
Unable to update this issue at this time.
'
);
});
});
it
(
'
fails to closes an issue with HTTP error
'
,
function
()
{
it
(
'
fails to closes an issue with HTTP error
'
,
function
()
{
var
$btnClose
,
$btnReopen
;
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
expect
(
req
.
type
).
toBe
(
'
PUT
'
);
expectPendingRequest
(
req
,
$btnClose
);
expect
(
req
.
url
).
toBe
(
'
http://goesnowhere.nothing/whereami
'
);
req
.
error
();
return
req
.
error
();
});
});
$btnClose
=
$
(
'
a.btn-close
'
);
$btnReopen
=
$
(
'
a.btn-reopen
'
);
$btnClose
.
attr
(
'
href
'
,
INVALID_URL
);
$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
'
);
$btnClose
.
trigger
(
'
click
'
);
expect
(
$btnReopen
).
toBeHidden
();
expect
(
$btnClose
).
toBeVisible
();
expectIssueState
(
true
);
expect
(
$
(
'
div.status-box-closed
'
)).
toBeHidden
();
expect
(
$btnClose
).
toHaveProp
(
'
disabled
'
,
true
);
expect
(
$
(
'
div.status-box-open
'
)).
toBeVisible
();
expectErrorMessage
();
expect
(
$
(
'
div.flash-alert
'
)).
toBeVisible
();
});
return
expect
(
$
(
'
div.flash-alert
'
).
text
()).
toBe
(
'
Unable to update this issue at this time.
'
);
});
describe
(
'
reopen issue
'
,
function
()
{
fixture
.
preload
(
'
issues_show.html
'
);
beforeEach
(
function
()
{
fixture
.
load
(
'
issues_show.html
'
);
findElements
();
this
.
issue
=
new
Issue
();
// TODO: fixture is an open issue, we should replace it by a closed issue
expectIssueState
(
true
);
});
});
return
it
(
'
reopens an issue
'
,
function
()
{
var
$btnClose
,
$btnReopen
;
it
(
'
reopens an issue
'
,
function
()
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
expect
(
req
.
type
).
toBe
(
'
PUT
'
);
expectPendingRequest
(
req
,
$btnReopen
);
expect
(
req
.
url
).
toBe
(
'
http://gitlab.com/issues/6/reopen
'
);
req
.
success
({
return
req
.
success
({
id
:
34
id
:
34
});
});
});
});
$btnClose
=
$
(
'
a.btn-close
'
);
$btnReopen
=
$
(
'
a.btn-reopen
'
);
expect
(
$btnReopen
.
text
()).
toBe
(
'
Reopen
'
);
$btnReopen
.
trigger
(
'
click
'
);
$btnReopen
.
trigger
(
'
click
'
);
expect
(
$btnReopen
).
toBeHidden
();
expect
(
$btnClose
).
toBeVisible
();
expectIssueState
(
true
);
expect
(
$
(
'
div.status-box-open
'
)).
toBeVisible
();
expect
(
$btnReopen
).
toHaveProp
(
'
disabled
'
,
false
);
return
expect
(
$
(
'
div.status-box-closed
'
)).
toBeHidden
();
});
});
});
});
...
...
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