Use $.ajax when testing to not break jquery.mockjax

This commit is contained in:
Piotr Sarnacki 2013-05-07 19:13:54 +02:00
parent 070d863588
commit 07cd8233d4
3 changed files with 7 additions and 7 deletions

View File

@ -33,7 +33,7 @@ Travis.ajax = Em.Object.create
options.headers ||= {}
options.headers['Authorization'] ||= "token #{token}"
url = "#{endpoint}#{url}"
options.url = url = "#{endpoint}#{url}"
options.type = method
options.dataType = options.dataType || 'json'
options.context = this
@ -58,6 +58,11 @@ Travis.ajax = Em.Object.create
options = $.extend(options, Travis.ajax.DEFAULT_OPTIONS)
if Travis.testing
# we use jquery.mockjax for test, I don't want to hack it or rewrite it,
# so let's just pretend we still use ajax if testing mode is on
return $.ajax(options)
if options.data && (method == "GET" || method == "HEAD")
params = []
for key, value of options.data

View File

@ -28,3 +28,4 @@ minispade.require 'app'
now = -> new Date('2012-07-02T00:03:00Z')
$.timeago.settings.nowFunction = -> now().getTime()
Travis.currentDate = now
Travis.testing = true

View File

@ -1,6 +0,0 @@
describe 'Travis.Log.Request', ->
it 'constructs s3 url for log', ->
Travis.config.api_endpoint = 'api.travis-ci.org'
request = Travis.Log.Request.create(id: 10)
s3Url = "https://s3.amazonaws.com/archive.travis-ci.org/jobs/10/log.txt"
expect( request.s3Url() ).toEqual(s3Url)