Permalink
Browse files

Merge pull request #31002 from ta1kt0me/call_ajax_without_beforeSend

Call Rails.ajax without beforeSend
  • Loading branch information...
guilleiguaran committed Oct 30, 2017
2 parents 8479b79 + 8b22725 commit ee44c1b6f1ca3a8ee685807a940cf02101ed5141
@@ -21,7 +21,7 @@ Rails.ajax = (options) ->
options.error?(response, xhr.statusText, xhr)
options.complete?(xhr, xhr.statusText)
unless options.beforeSend?(xhr, options)
if options.beforeSend? && !options.beforeSend(xhr, options)
return false
if xhr.readyState is XMLHttpRequest.OPENED
@@ -0,0 +1,27 @@
(function() {
module('call-ajax', {
setup: function() {
$('#qunit-fixture')
.append($('<a />', { href: '#' }))
}
})
asyncTest('call ajax without "ajax:beforeSend"', 1, function() {
var link = $('#qunit-fixture a')
link.bindNative('click', function() {
Rails.ajax({
type: 'get',
url: '/',
success: function() {
ok(true, 'calling request in ajax:success')
}
})
})
link.triggerNative('click')
setTimeout(function() { start() }, 13)
})
})()
@@ -1,6 +1,6 @@
<% @title = "rails-ujs test" %>
<%= test_to 'data-confirm', 'data-remote', 'data-disable', 'data-disable-with', 'call-remote', 'call-remote-callbacks', 'data-method', 'override', 'csrf-refresh', 'csrf-token' %>
<%= test_to 'data-confirm', 'data-remote', 'data-disable', 'data-disable-with', 'call-remote', 'call-remote-callbacks', 'data-method', 'override', 'csrf-refresh', 'csrf-token', 'call-ajax' %>
<h1 id="qunit-header"><%= @title %></h1>
<h2 id="qunit-banner"></h2>

0 comments on commit ee44c1b

Please sign in to comment.