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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
848d868b
Commit
848d868b
authored
Jul 05, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue_spec and merge_request_spec for report toggle changes
parent
d7c383a0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
28 deletions
+26
-28
app/assets/javascripts/issue.js
app/assets/javascripts/issue.js
+6
-4
app/assets/javascripts/merge_request.js
app/assets/javascripts/merge_request.js
+2
-2
spec/javascripts/issue_spec.js
spec/javascripts/issue_spec.js
+12
-18
spec/javascripts/merge_request_spec.js
spec/javascripts/merge_request_spec.js
+6
-4
No files found.
app/assets/javascripts/issue.js
View file @
848d868b
...
@@ -43,9 +43,6 @@ class Issue {
...
@@ -43,9 +43,6 @@ class Issue {
initIssueBtnEventListeners
()
{
initIssueBtnEventListeners
()
{
const
issueFailMessage
=
'
Unable to update this issue at this time.
'
;
const
issueFailMessage
=
'
Unable to update this issue at this time.
'
;
const
isClosedBadge
=
$
(
'
div.status-box-closed
'
);
const
isOpenBadge
=
$
(
'
div.status-box-open
'
);
const
projectIssuesCounter
=
$
(
'
.issue_counter
'
);
return
$
(
document
).
on
(
'
click
'
,
'
a.btn-close, a.btn-reopen
'
,
(
e
)
=>
{
return
$
(
document
).
on
(
'
click
'
,
'
a.btn-close, a.btn-reopen
'
,
(
e
)
=>
{
var
$button
,
shouldSubmit
,
url
;
var
$button
,
shouldSubmit
,
url
;
...
@@ -66,6 +63,10 @@ class Issue {
...
@@ -66,6 +63,10 @@ class Issue {
})
})
.
fail
(()
=>
new
Flash
(
issueFailMessage
))
.
fail
(()
=>
new
Flash
(
issueFailMessage
))
.
done
((
data
)
=>
{
.
done
((
data
)
=>
{
const
isClosedBadge
=
$
(
'
div.status-box-closed
'
);
const
isOpenBadge
=
$
(
'
div.status-box-open
'
);
const
projectIssuesCounter
=
$
(
'
.issue_counter
'
);
if
(
'
id
'
in
data
)
{
if
(
'
id
'
in
data
)
{
$
(
document
).
trigger
(
'
issuable:change
'
);
$
(
document
).
trigger
(
'
issuable:change
'
);
...
@@ -91,7 +92,8 @@ class Issue {
...
@@ -91,7 +92,8 @@ class Issue {
}
else
{
}
else
{
new
Flash
(
issueFailMessage
);
new
Flash
(
issueFailMessage
);
}
}
})
.
then
(()
=>
{
this
.
disableCloseReopenButton
(
$button
,
false
);
this
.
disableCloseReopenButton
(
$button
,
false
);
});
});
});
});
...
...
app/assets/javascripts/merge_request.js
View file @
848d868b
...
@@ -22,12 +22,12 @@ import CloseReopenReportToggle from './close_reopen_report_toggle';
...
@@ -22,12 +22,12 @@ import CloseReopenReportToggle from './close_reopen_report_toggle';
return
_this
.
showAllCommits
();
return
_this
.
showAllCommits
();
};
};
})(
this
));
})(
this
));
this
.
initTabs
();
this
.
initTabs
();
this
.
initMRBtnListeners
();
this
.
initMRBtnListeners
();
this
.
initCommitMessageListeners
();
this
.
initCommitMessageListeners
();
this
.
initCloseReopenReport
();
this
.
initCloseReopenReport
();
if
(
$
(
"
a.btn-close
"
).
length
)
{
if
(
$
(
"
a.btn-close
"
).
length
)
{
this
.
taskList
=
new
gl
.
TaskList
({
this
.
taskList
=
new
gl
.
TaskList
({
dataType
:
'
merge_request
'
,
dataType
:
'
merge_request
'
,
...
...
spec/javascripts/issue_spec.js
View file @
848d868b
...
@@ -4,7 +4,7 @@ import CloseReopenReportToggle from '~/close_reopen_report_toggle';
...
@@ -4,7 +4,7 @@ import CloseReopenReportToggle from '~/close_reopen_report_toggle';
import
'
~/lib/utils/text_utility
'
;
import
'
~/lib/utils/text_utility
'
;
describe
(
'
Issue
'
,
function
()
{
describe
(
'
Issue
'
,
function
()
{
let
$boxClosed
,
$boxOpen
,
$btn
Close
,
$btnReopen
;
let
$boxClosed
,
$boxOpen
,
$btn
;
preloadFixtures
(
'
issues/closed-issue.html.raw
'
);
preloadFixtures
(
'
issues/closed-issue.html.raw
'
);
preloadFixtures
(
'
issues/issue-with-task-list.html.raw
'
);
preloadFixtures
(
'
issues/issue-with-task-list.html.raw
'
);
...
@@ -20,9 +20,7 @@ describe('Issue', function() {
...
@@ -20,9 +20,7 @@ describe('Issue', function() {
function
expectIssueState
(
isIssueOpen
)
{
function
expectIssueState
(
isIssueOpen
)
{
expectVisibility
(
$boxClosed
,
!
isIssueOpen
);
expectVisibility
(
$boxClosed
,
!
isIssueOpen
);
expectVisibility
(
$boxOpen
,
isIssueOpen
);
expectVisibility
(
$boxOpen
,
isIssueOpen
);
expect
(
$btn
).
toHaveText
(
isIssueOpen
?
'
Close issue
'
:
'
Reopen issue
'
);
expectVisibility
(
$btnClose
,
isIssueOpen
);
expectVisibility
(
$btnReopen
,
!
isIssueOpen
);
}
}
function
expectNewBranchButtonState
(
isPending
,
canCreate
)
{
function
expectNewBranchButtonState
(
isPending
,
canCreate
)
{
...
@@ -57,7 +55,7 @@ describe('Issue', function() {
...
@@ -57,7 +55,7 @@ describe('Issue', function() {
}
}
}
}
function
findElements
()
{
function
findElements
(
isIssueInitiallyOpen
)
{
$boxClosed
=
$
(
'
div.status-box-closed
'
);
$boxClosed
=
$
(
'
div.status-box-closed
'
);
expect
(
$boxClosed
).
toExist
();
expect
(
$boxClosed
).
toExist
();
expect
(
$boxClosed
).
toHaveText
(
'
Closed
'
);
expect
(
$boxClosed
).
toHaveText
(
'
Closed
'
);
...
@@ -66,13 +64,9 @@ describe('Issue', function() {
...
@@ -66,13 +64,9 @@ describe('Issue', function() {
expect
(
$boxOpen
).
toExist
();
expect
(
$boxOpen
).
toExist
();
expect
(
$boxOpen
).
toHaveText
(
'
Open
'
);
expect
(
$boxOpen
).
toHaveText
(
'
Open
'
);
$btnClose
=
$
(
'
.btn-close.btn-grouped
'
);
$btn
=
$
(
'
.js-issuable-close-button
'
);
expect
(
$btnClose
).
toExist
();
expect
(
$btn
).
toExist
();
expect
(
$btnClose
).
toHaveText
(
'
Close issue
'
);
expect
(
$btn
).
toHaveText
(
isIssueInitiallyOpen
?
'
Close issue
'
:
'
Reopen issue
'
);
$btnReopen
=
$
(
'
.btn-reopen.btn-grouped
'
);
expect
(
$btnReopen
).
toExist
();
expect
(
$btnReopen
).
toHaveText
(
'
Reopen issue
'
);
}
}
describe
(
'
task lists
'
,
function
()
{
describe
(
'
task lists
'
,
function
()
{
...
@@ -99,7 +93,6 @@ describe('Issue', function() {
...
@@ -99,7 +93,6 @@ describe('Issue', function() {
function
ajaxSpy
(
req
)
{
function
ajaxSpy
(
req
)
{
if
(
req
.
url
===
this
.
$triggeredButton
.
attr
(
'
href
'
))
{
if
(
req
.
url
===
this
.
$triggeredButton
.
attr
(
'
href
'
))
{
expect
(
req
.
type
).
toBe
(
'
PUT
'
);
expect
(
req
.
type
).
toBe
(
'
PUT
'
);
expect
(
this
.
$triggeredButton
).
toHaveProp
(
'
disabled
'
,
true
);
expectNewBranchButtonState
(
true
,
false
);
expectNewBranchButtonState
(
true
,
false
);
return
this
.
issueStateDeferred
;
return
this
.
issueStateDeferred
;
}
else
if
(
req
.
url
===
Issue
.
createMrDropdownWrap
.
dataset
.
canCreatePath
)
{
}
else
if
(
req
.
url
===
Issue
.
createMrDropdownWrap
.
dataset
.
canCreatePath
)
{
...
@@ -119,10 +112,11 @@ describe('Issue', function() {
...
@@ -119,10 +112,11 @@ describe('Issue', function() {
loadFixtures
(
'
issues/closed-issue.html.raw
'
);
loadFixtures
(
'
issues/closed-issue.html.raw
'
);
}
}
findElements
();
findElements
(
isIssueInitiallyOpen
);
this
.
issue
=
new
Issue
();
this
.
issue
=
new
Issue
();
expectIssueState
(
isIssueInitiallyOpen
);
expectIssueState
(
isIssueInitiallyOpen
);
this
.
$triggeredButton
=
isIssueInitiallyOpen
?
$btnClose
:
$btnReopen
;
this
.
$triggeredButton
=
$btn
;
this
.
$projectIssuesCounter
=
$
(
'
.issue_counter
'
);
this
.
$projectIssuesCounter
=
$
(
'
.issue_counter
'
);
this
.
$projectIssuesCounter
.
text
(
'
1,001
'
);
this
.
$projectIssuesCounter
.
text
(
'
1,001
'
);
...
@@ -143,7 +137,7 @@ describe('Issue', function() {
...
@@ -143,7 +137,7 @@ describe('Issue', function() {
});
});
expectIssueState
(
!
isIssueInitiallyOpen
);
expectIssueState
(
!
isIssueInitiallyOpen
);
expect
(
this
.
$triggeredButton
).
toHaveProp
(
'
disabled
'
,
false
);
expect
(
this
.
$triggeredButton
.
get
(
0
).
getAttribute
(
'
disabled
'
)).
toBeNull
(
);
expect
(
this
.
$projectIssuesCounter
.
text
()).
toBe
(
isIssueInitiallyOpen
?
'
1,000
'
:
'
1,002
'
);
expect
(
this
.
$projectIssuesCounter
.
text
()).
toBe
(
isIssueInitiallyOpen
?
'
1,000
'
:
'
1,002
'
);
expectNewBranchButtonState
(
false
,
!
isIssueInitiallyOpen
);
expectNewBranchButtonState
(
false
,
!
isIssueInitiallyOpen
);
});
});
...
@@ -158,7 +152,7 @@ describe('Issue', function() {
...
@@ -158,7 +152,7 @@ describe('Issue', function() {
});
});
expectIssueState
(
isIssueInitiallyOpen
);
expectIssueState
(
isIssueInitiallyOpen
);
expect
(
this
.
$triggeredButton
).
toHaveProp
(
'
disabled
'
,
false
);
expect
(
this
.
$triggeredButton
.
get
(
0
).
getAttribute
(
'
disabled
'
)).
toBeNull
(
);
expectErrorMessage
();
expectErrorMessage
();
expect
(
this
.
$projectIssuesCounter
.
text
()).
toBe
(
'
1,001
'
);
expect
(
this
.
$projectIssuesCounter
.
text
()).
toBe
(
'
1,001
'
);
expectNewBranchButtonState
(
false
,
isIssueInitiallyOpen
);
expectNewBranchButtonState
(
false
,
isIssueInitiallyOpen
);
...
@@ -172,7 +166,7 @@ describe('Issue', function() {
...
@@ -172,7 +166,7 @@ describe('Issue', function() {
});
});
expectIssueState
(
isIssueInitiallyOpen
);
expectIssueState
(
isIssueInitiallyOpen
);
expect
(
this
.
$triggeredButton
).
toHaveProp
(
'
disabled
'
,
true
);
expect
(
this
.
$triggeredButton
.
get
(
0
).
getAttribute
(
'
disabled
'
)).
toBeNull
(
);
expectErrorMessage
();
expectErrorMessage
();
expect
(
this
.
$projectIssuesCounter
.
text
()).
toBe
(
'
1,001
'
);
expect
(
this
.
$projectIssuesCounter
.
text
()).
toBe
(
'
1,001
'
);
expectNewBranchButtonState
(
false
,
isIssueInitiallyOpen
);
expectNewBranchButtonState
(
false
,
isIssueInitiallyOpen
);
...
...
spec/javascripts/merge_request_spec.js
View file @
848d868b
...
@@ -31,11 +31,11 @@ import CloseReopenReportToggle from '~/close_reopen_report_toggle';
...
@@ -31,11 +31,11 @@ import CloseReopenReportToggle from '~/close_reopen_report_toggle';
describe
(
'
class constructor
'
,
()
=>
{
describe
(
'
class constructor
'
,
()
=>
{
it
(
'
calls .initCloseReopenReport
'
,
()
=>
{
it
(
'
calls .initCloseReopenReport
'
,
()
=>
{
spyOn
(
MergeRequest
,
'
initCloseReopenReport
'
);
spyOn
(
MergeRequest
.
prototype
,
'
initCloseReopenReport
'
);
new
MergeRequest
();
// eslint-disable-line no-new
const
mergeRequest
=
new
MergeRequest
();
expect
(
M
ergeRequest
.
initCloseReopenReport
).
toHaveBeenCalled
();
expect
(
m
ergeRequest
.
initCloseReopenReport
).
toHaveBeenCalled
();
});
});
});
});
...
@@ -46,11 +46,13 @@ import CloseReopenReportToggle from '~/close_reopen_report_toggle';
...
@@ -46,11 +46,13 @@ import CloseReopenReportToggle from '~/close_reopen_report_toggle';
const
dropdownList
=
{};
const
dropdownList
=
{};
const
button
=
{};
const
button
=
{};
const
mergeRequest
=
new
MergeRequest
();
spyOn
(
CloseReopenReportToggle
.
prototype
,
'
initDroplab
'
);
spyOn
(
CloseReopenReportToggle
.
prototype
,
'
initDroplab
'
);
spyOn
(
document
,
'
querySelector
'
).
and
.
returnValue
(
container
);
spyOn
(
document
,
'
querySelector
'
).
and
.
returnValue
(
container
);
container
.
querySelector
.
and
.
returnValues
(
dropdownTrigger
,
dropdownList
,
button
);
container
.
querySelector
.
and
.
returnValues
(
dropdownTrigger
,
dropdownList
,
button
);
M
ergeRequest
.
initCloseReopenReport
();
m
ergeRequest
.
initCloseReopenReport
();
expect
(
document
.
querySelector
).
toHaveBeenCalledWith
(
'
.js-issuable-close-dropdown
'
);
expect
(
document
.
querySelector
).
toHaveBeenCalledWith
(
'
.js-issuable-close-dropdown
'
);
expect
(
container
.
querySelector
).
toHaveBeenCalledWith
(
'
.js-issuable-close-toggle
'
);
expect
(
container
.
querySelector
).
toHaveBeenCalledWith
(
'
.js-issuable-close-toggle
'
);
...
...
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