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 ...@@ -27,6 +27,7 @@ class @Issue
url: url, url: url,
error: (jqXHR, textStatus, errorThrown) -> error: (jqXHR, textStatus, errorThrown) ->
issueStatus = if isClose then 'close' else 'open' issueStatus = if isClose then 'close' else 'open'
new Flash("Issues update failed", 'alert')
success: (data, textStatus, jqXHR) -> success: (data, textStatus, jqXHR) ->
if data.saved if data.saved
$this.addClass('hidden') $this.addClass('hidden')
...@@ -39,6 +40,7 @@ class @Issue ...@@ -39,6 +40,7 @@ class @Issue
$('div.issue-box-closed').addClass('hidden') $('div.issue-box-closed').addClass('hidden')
$('div.issue-box-open').removeClass('hidden') $('div.issue-box-open').removeClass('hidden')
else else
new Flash("Issues update failed", 'alert')
$this.prop('disabled', false) $this.prop('disabled', false)
disableTaskList: -> disableTaskList: ->
......
...@@ -31,41 +31,32 @@ describe 'reopen/close issue', -> ...@@ -31,41 +31,32 @@ describe 'reopen/close issue', ->
expect(obj.url).toBe('http://gitlab/issues/6/close') expect(obj.url).toBe('http://gitlab/issues/6/close')
obj.success saved: true obj.success saved: true
# setup
$btnClose = $('a.btn-close') $btnClose = $('a.btn-close')
$btnReopen = $('a.btn-reopen') $btnReopen = $('a.btn-reopen')
expect($btnReopen.toBeHidden()) expect($btnReopen.toBeHidden())
expect($btnClose.text()).toBe('Close') expect($btnClose.text()).toBe('Close')
expect(typeof $btnClose.prop('disabled')).toBe('undefined') expect(typeof $btnClose.prop('disabled')).toBe('undefined')
# excerize
$btnClose.trigger('click') $btnClose.trigger('click')
# verify
expect($btnClose.toBeHidden()) expect($btnClose.toBeHidden())
expect($btnReopen.toBeVisible()) expect($btnReopen.toBeVisible())
expect($('div.issue-box-open').toBeVisible()) expect($('div.issue-box-open').toBeVisible())
expect($('div.issue-box-closed').toBeHidden()) expect($('div.issue-box-closed').toBeHidden())
# teardown
it 'reopens an issue', -> it 'reopens an issue', ->
$.ajax = (obj) -> $.ajax = (obj) ->
expect(obj.type).toBe('PUT') expect(obj.type).toBe('PUT')
expect(obj.url).toBe('http://gitlab/issues/6/reopen') expect(obj.url).toBe('http://gitlab/issues/6/reopen')
obj.success saved: true obj.success saved: true
# setup
$btnClose = $('a.btn-close') $btnClose = $('a.btn-close')
$btnReopen = $('a.btn-reopen') $btnReopen = $('a.btn-reopen')
expect($btnReopen.text()).toBe('Reopen') expect($btnReopen.text()).toBe('Reopen')
# excerize
$btnReopen.trigger('click') $btnReopen.trigger('click')
# verify
expect($btnReopen.toBeHidden()) expect($btnReopen.toBeHidden())
expect($btnClose.toBeVisible()) expect($btnClose.toBeVisible())
expect($('div.issue-box-open').toBeVisible()) expect($('div.issue-box-open').toBeVisible())
expect($('div.issue-box-closed').toBeHidden()) 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