Sha256: d30f8ee77fead4bd154dd95e0431c38cf9d588886281f365e1482ab8aef76667

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

(function() {

var realHref

module('override', {
  setup: function() {
    realHref = $.quails.href
    $('#qunit-fixture')
      .append($('<a />', {
        href: '/real/href', 'data-remote': 'true', 'data-method': 'delete', 'data-href': '/data/href'
      }))
  },
  teardown: function() {
    $.quails.href = realHref
  }
})

asyncTest('the getter for an element\'s href is publicly accessible', 1, function() {
  ok($.quails.href)
  start()
})

asyncTest('the getter for an element\'s href is overridable', 1, function() {
  $.quails.href = function(element) { return $(element).data('href') }
  $('#qunit-fixture a')
    .bindNative('ajax:beforeSend', function(e, xhr, options) {
      equal('/data/href', options.url)
      return false
    })
    .triggerNative('click')
  start()
})

asyncTest('the getter for an element\'s href works normally if not overridden', 1, function() {
  $('#qunit-fixture a')
    .bindNative('ajax:beforeSend', function(e, xhr, options) {
      equal(location.protocol + '//' + location.host + '/real/href', options.url)
      return false
    })
    .triggerNative('click')
  start()
})

asyncTest('the event selector strings are overridable', 1, function() {
  ok($.quails.linkClickSelector.indexOf(', a[data-custom-remote-link]') != -1, 'linkClickSelector contains custom selector')
  start()
})

asyncTest('including quails-ujs multiple times throws error', 1, function() {
  throws(function() {
    Quails.start()
  }, 'appending quails.js again throws error')
  setTimeout(function() { start() }, 50)
})

})()

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-on-quails-0.1.0 actionview/test/ujs/public/test/override.js