Commit 45347914 authored by Jacob Schatz's avatar Jacob Schatz

adds alerts for when http request errors out in some way.

parent 801b801b
......@@ -27,6 +27,7 @@ class @Issue
url: url,
error: (jqXHR, textStatus, errorThrown) ->
issueStatus = if isClose then 'close' else 'open'
new Flash("Issues update failed", 'alert')
success: (data, textStatus, jqXHR) ->
if data.saved
$this.addClass('hidden')
......@@ -39,6 +40,7 @@ class @Issue
$('div.issue-box-closed').addClass('hidden')
$('div.issue-box-open').removeClass('hidden')
else
new Flash("Issues update failed", 'alert')
$this.prop('disabled', false)
disableTaskList: ->
......
......@@ -31,41 +31,32 @@ describe 'reopen/close issue', ->
expect(obj.url).toBe('http://gitlab/issues/6/close')
obj.success saved: true
# setup
$btnClose = $('a.btn-close')
$btnReopen = $('a.btn-reopen')
expect($btnReopen.toBeHidden())
expect($btnClose.text()).toBe('Close')
expect(typeof $btnClose.prop('disabled')).toBe('undefined')
# excerize
$btnClose.trigger('click')
# verify
expect($btnClose.toBeHidden())
expect($btnReopen.toBeVisible())
expect($('div.issue-box-open').toBeVisible())
expect($('div.issue-box-closed').toBeHidden())
# teardown
it 'reopens an issue', ->
$.ajax = (obj) ->
expect(obj.type).toBe('PUT')
expect(obj.url).toBe('http://gitlab/issues/6/reopen')
obj.success saved: true
# setup
$btnClose = $('a.btn-close')
$btnReopen = $('a.btn-reopen')
expect($btnReopen.text()).toBe('Reopen')
# excerize
$btnReopen.trigger('click')
# verify
expect($btnReopen.toBeHidden())
expect($btnClose.toBeVisible())
expect($('div.issue-box-open').toBeVisible())
expect($('div.issue-box-closed').toBeHidden())
\ No newline at end of file
# teardown
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment