travis-web/assets/scripts/spec/spec_helper.coffee
Piotr Sarnacki 018eafe84b Fix problem with getting started template rendering on first sync
When first sync template is displayed, user usually doesn't have any
repos, which also triggers rendering of getting started template. The
fix for this is to handle the action to render getting started page on
first sync and do nothing in such case.

I also added a test to ensure that it works correctly.
2013-10-29 20:48:27 +01:00

50 lines
1.3 KiB
CoffeeScript

document.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
Travis.rootElement = '#ember-testing';
Travis.setupForTesting();
Travis.injectTestHelpers();
oldSetup = Travis.setup
Travis.ready = ->
oldSetup.apply(this, arguments)
Travis.auth.signOut()
window.exists = (selector) ->
return !!find(selector).length
Ember.Container.prototype.stub = (fullName, instance) ->
instance.destroy = instance.destroy || (->)
this.cache.dict[fullName] = instance
window.signInUser = (data) ->
data ||= {}
userData = {
id: 1
email: 'tyrion@example.org'
login: 'tyrion'
token: 'abcdef'
}
userData = Ember.merge(userData, data)
# for now let's just use harcoded data to log in the user,
# we may extend it in the future to pass specific user data
Travis.auth.signIn
user: userData
token: 'abcdef'
#@app = (url, options = {}) ->
# # TODO: this should wait till app is initialized, not some
# # arbitrary amount of time
# waits(50)
# runs ->
# Travis.reset()
# Travis.auth.signOut()
#
# if options.user
# signInUser()
# url = "/#{url}" unless url.match /^\//
# visit(url)
now = -> new Date('2012-07-02T00:03:00Z')
$.timeago.settings.nowFunction = -> now().getTime()
Travis.currentDate = now