2015-05-04 23:06:57 -04:00
|
|
|
#= require issue
|
|
|
|
|
|
|
|
describe 'Issue', ->
|
|
|
|
describe 'task lists', ->
|
2015-05-06 16:54:34 -04:00
|
|
|
fixture.preload('issues_show.html')
|
2015-05-04 23:06:57 -04:00
|
|
|
|
|
|
|
beforeEach ->
|
2015-05-06 16:54:34 -04:00
|
|
|
fixture.load('issues_show.html')
|
2015-05-04 23:06:57 -04:00
|
|
|
@issue = new Issue()
|
|
|
|
|
2015-05-06 16:54:34 -04:00
|
|
|
it 'modifies the Markdown field', ->
|
2015-05-06 17:02:14 -04:00
|
|
|
spyOn(jQuery, 'ajax').and.stub()
|
2015-05-06 16:54:34 -04:00
|
|
|
$('input[type=checkbox]').attr('checked', true).trigger('change')
|
|
|
|
expect($('.js-task-list-field').val()).toBe('- [x] Task List Item')
|
|
|
|
|
2015-05-04 23:06:57 -04:00
|
|
|
it 'submits an ajax request on tasklist:changed', ->
|
2015-05-06 17:02:14 -04:00
|
|
|
spyOn(jQuery, 'ajax').and.callFake (req) ->
|
2015-05-04 23:06:57 -04:00
|
|
|
expect(req.type).toBe('PATCH')
|
|
|
|
expect(req.url).toBe('/foo')
|
|
|
|
expect(req.data.issue.description).not.toBe(null)
|
|
|
|
|
|
|
|
$('.js-task-list-field').trigger('tasklist:changed')
|
2015-12-21 13:06:09 -05:00
|
|
|
describe 'reopen/close issue', ->
|
|
|
|
fixture.preload('issues_show.html')
|
|
|
|
beforeEach ->
|
|
|
|
fixture.load('issues_show.html')
|
|
|
|
@issue = new Issue()
|
|
|
|
it 'closes an issue', ->
|
2016-01-07 12:27:01 -05:00
|
|
|
spyOn(jQuery, 'ajax').and.callFake (req) ->
|
|
|
|
expect(req.type).toBe('PUT')
|
|
|
|
expect(req.url).toBe('http://gitlab.com/issues/6/close')
|
|
|
|
req.success saved: true
|
2015-12-21 16:27:52 -05:00
|
|
|
|
2015-12-21 13:06:09 -05:00
|
|
|
$btnClose = $('a.btn-close')
|
|
|
|
$btnReopen = $('a.btn-reopen')
|
2015-12-23 16:56:36 -05:00
|
|
|
expect($btnReopen).toBeHidden()
|
2015-12-21 13:06:09 -05:00
|
|
|
expect($btnClose.text()).toBe('Close')
|
|
|
|
expect(typeof $btnClose.prop('disabled')).toBe('undefined')
|
2015-12-21 16:27:52 -05:00
|
|
|
|
2015-12-21 13:06:09 -05:00
|
|
|
$btnClose.trigger('click')
|
2015-12-21 16:27:52 -05:00
|
|
|
|
2015-12-23 16:56:36 -05:00
|
|
|
expect($btnReopen).toBeVisible()
|
|
|
|
expect($btnClose).toBeHidden()
|
|
|
|
expect($('div.status-box-closed')).toBeVisible()
|
|
|
|
expect($('div.status-box-open')).toBeHidden()
|
2015-12-21 16:27:52 -05:00
|
|
|
|
2016-01-06 07:33:50 -05:00
|
|
|
it 'fails to close an issue with success:false', ->
|
2015-12-23 17:41:05 -05:00
|
|
|
|
2016-01-07 12:27:01 -05:00
|
|
|
spyOn(jQuery, 'ajax').and.callFake (req) ->
|
|
|
|
expect(req.type).toBe('PUT')
|
|
|
|
expect(req.url).toBe('http://goesnowhere.nothing/whereami')
|
|
|
|
req.success saved: false
|
2015-12-23 17:41:05 -05:00
|
|
|
|
|
|
|
$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', ->
|
|
|
|
|
2016-01-07 12:27:01 -05:00
|
|
|
spyOn(jQuery, 'ajax').and.callFake (req) ->
|
|
|
|
expect(req.type).toBe('PUT')
|
|
|
|
expect(req.url).toBe('http://goesnowhere.nothing/whereami')
|
|
|
|
req.error()
|
2015-12-23 17:41:05 -05:00
|
|
|
|
|
|
|
$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.')
|
|
|
|
|
2015-12-21 13:06:09 -05:00
|
|
|
it 'reopens an issue', ->
|
2016-01-07 12:27:01 -05:00
|
|
|
spyOn(jQuery, 'ajax').and.callFake (req) ->
|
|
|
|
expect(req.type).toBe('PUT')
|
|
|
|
expect(req.url).toBe('http://gitlab.com/issues/6/reopen')
|
|
|
|
req.success saved: true
|
2015-12-21 16:27:52 -05:00
|
|
|
|
2015-12-21 13:06:09 -05:00
|
|
|
$btnClose = $('a.btn-close')
|
|
|
|
$btnReopen = $('a.btn-reopen')
|
|
|
|
expect($btnReopen.text()).toBe('Reopen')
|
2015-12-21 16:27:52 -05:00
|
|
|
|
2015-12-21 13:06:09 -05:00
|
|
|
$btnReopen.trigger('click')
|
2015-12-21 16:27:52 -05:00
|
|
|
|
2015-12-23 16:56:36 -05:00
|
|
|
expect($btnReopen).toBeHidden()
|
|
|
|
expect($btnClose).toBeVisible()
|
|
|
|
expect($('div.status-box-open')).toBeVisible()
|
|
|
|
expect($('div.status-box-closed')).toBeHidden()
|