aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/ujs/public/test/csrf-refresh.js
blob: e302042542f7d2d54e160c335478bd7cb18a4a0e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(function() {

module('csrf-refresh', {})

asyncTest('refresh all csrf tokens', 1, function() {
  var correctToken = 'cf50faa3fe97702ca1ae'

  var form = $('<form />')
  var input = $('<input>').attr({ type: 'hidden', name: 'authenticity_token', id: 'authenticity_token', value: 'foo' })
  input.appendTo(form)

  $('#qunit-fixture')
    .append('<meta name="csrf-param" content="authenticity_token"/>')
    .append('<meta name="csrf-token" content="' + correctToken + '"/>')
    .append(form)

  $.rails.refreshCSRFTokens()
  currentToken = $('#qunit-fixture #authenticity_token').val()

  start()
  equal(currentToken, correctToken)
})

})()