Skip to content
Snippets Groups Projects
Commit 45347914 authored by Jacob Schatz's avatar Jacob Schatz
Browse files

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

parent 801b801b
No related branches found
No related tags found
1 merge request!2164open and close issue via ajax request. With tests
Pipeline #
Loading
Loading
@@ -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')
Loading
Loading
@@ -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: ->
Loading
Loading
Loading
Loading
@@ -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())
# teardown
\ No newline at end of file
expect($('div.issue-box-closed').toBeHidden())
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment