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
Kazuhiko Shiozaki
gitlab-ce
Commits
f7164201
Commit
f7164201
authored
Jan 06, 2016
by
Jacob Schatz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds tests (and passes them) for ajax open and close merge requests.
parent
cbdc8dd4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
2 deletions
+100
-2
spec/javascripts/fixtures/merge_requests_show.html.haml
spec/javascripts/fixtures/merge_requests_show.html.haml
+11
-1
spec/javascripts/issue_spec.js.coffee
spec/javascripts/issue_spec.js.coffee
+1
-1
spec/javascripts/merge_request_spec.js.coffee
spec/javascripts/merge_request_spec.js.coffee
+88
-0
No files found.
spec/javascripts/fixtures/merge_requests_show.html.haml
View file @
f7164201
%a
.btn-close
:css
.hidden
{
display
:
none
!important
}
.flash-container
.flash-alert
.flash-notice
.status-box.status-box-open
Open
.status-box.status-box-closed.hidden
Closed
%a
.btn-close
{
"href"
=>
"http://gitlab.com/merge_requests/6/close"
}
Close
%a
.btn-reopen.hidden
{
"href"
=>
"http://gitlab.com/merge_requests/6/reopen"
}
Reopen
.detail-page-description
.description.js-task-list-container
...
...
spec/javascripts/issue_spec.js.coffee
View file @
f7164201
...
...
@@ -44,7 +44,7 @@ describe 'reopen/close issue', ->
expect
(
$
(
'div.status-box-closed'
)).
toBeVisible
()
expect
(
$
(
'div.status-box-open'
)).
toBeHidden
()
it
'fails to close
s
an issue with success:false'
,
->
it
'fails to close an issue with success:false'
,
->
$
.
ajax
=
(
obj
)
->
expect
(
obj
.
type
).
toBe
(
'PUT'
)
...
...
spec/javascripts/merge_request_spec.js.coffee
View file @
f7164201
...
...
@@ -21,3 +21,91 @@ describe 'MergeRequest', ->
expect
(
req
.
data
.
merge_request
.
description
).
not
.
toBe
(
null
)
$
(
'.js-task-list-field'
).
trigger
(
'tasklist:changed'
)
describe
'reopen/close merge request'
,
->
fixture
.
preload
(
'merge_requests_show.html'
)
beforeEach
->
fixture
.
load
(
'merge_requests_show.html'
)
@
merge_request
=
new
MergeRequest
({})
it
'closes a merge request'
,
->
$
.
ajax
=
(
obj
)
->
expect
(
obj
.
type
).
toBe
(
'PUT'
)
expect
(
obj
.
url
).
toBe
(
'http://gitlab.com/merge_requests/6/close'
)
obj
.
success
saved
:
true
$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'
)
expect
(
$btnReopen
).
toBeVisible
()
expect
(
$btnClose
).
toBeHidden
()
expect
(
$
(
'div.status-box-closed'
)).
toBeVisible
()
expect
(
$
(
'div.status-box-open'
)).
toBeHidden
()
it
'fails to close a merge request 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 merge request 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 merge request at this time.'
)
it
'reopens a merge request'
,
->
$
.
ajax
=
(
obj
)
->
expect
(
obj
.
type
).
toBe
(
'PUT'
)
expect
(
obj
.
url
).
toBe
(
'http://gitlab.com/merge_requests/6/reopen'
)
obj
.
success
saved
:
true
$btnClose
=
$
(
'a.btn-close'
)
$btnReopen
=
$
(
'a.btn-reopen'
)
expect
(
$btnReopen
.
text
()).
toBe
(
'Reopen'
)
$btnReopen
.
trigger
(
'click'
)
expect
(
$btnReopen
).
toBeHidden
()
expect
(
$btnClose
).
toBeVisible
()
expect
(
$
(
'div.status-box-open'
)).
toBeVisible
()
expect
(
$
(
'div.status-box-closed'
)).
toBeHidden
()
\ No newline at end of file
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