Sha256: c51cbb594ab62ae8f3a3fa6a9b03815fb13033768111082887a9d606ff30e148
Contents?: true
Size: 1.65 KB
Versions: 35
Compression:
Stored size: 1.65 KB
Contents
describe "ajax error callbacks", -> beforeEach -> $('body').prepend('<form action="foobar" id="rails_ajax_form" data-remote="true"></form>') $('body').prepend('<div class="flash" style="display: none"></div') this.xhr = sinon.useFakeXMLHttpRequest() requests = this.requests = [] @xhr.onCreate = (xhr) -> requests.push(xhr) afterEach -> @xhr.restore(); $('#rails_ajax_form').remove() $('.flash').remove() describe ".ajax:error with server error", -> it 'shows the flash block with a div with the error', -> expect($('.flash')).not.toBeVisible() $('#rails_ajax_form').trigger('submit') @requests[0].respond(500, { "Content-Type": "text/html" }, '<b class="error">error</b>') expect($('.flash')).toBeVisible() expect($('.flash .error-details')).toBeVisible() expect($('.flash .error-details')).toHaveText('error') describe '.ajax:error with non-human-readable error details', -> it 'only shows a general error but no error details', -> expect($('.flash')).not.toBeVisible() $('#rails_ajax_form').trigger('submit') @requests[0].respond(500, { "Content-Type": "application/json" }, '<b class="error">error</b>') expect($('.flash')).toBeVisible() expect($('.flash .error-details')).not.toBeVisible() describe ".ajax:error with server timeout", -> it 'shows the flash block with an iframe', -> expect($('.flash')).not.toBeVisible() $('#rails_ajax_form').trigger('submit') @requests[0].respond(0, {}, '') expect($('.flash')).toBeVisible() expect($('.flash')).toContainHtml('Controleer je internetverbinding en probeer het nogmaals')
Version data entries
35 entries across 35 versions & 1 rubygems