Fix integration tests running and 2 first tests

This commit is contained in:
Piotr Sarnacki 2013-02-27 15:58:36 +01:00
parent 0f89da6dea
commit 02ff533774
6 changed files with 37 additions and 42 deletions

View File

@ -2,7 +2,7 @@ require 'travis/location'
require 'travis/line_number_parser'
Ember.Router.reopen
location: (if testMode? then Ember.HashLocation.create() else Travis.Location.create())
location: (if testMode? then Ember.NoneLocation.create() else Travis.Location.create())
handleURL: (url) ->
url = url.replace(/#.*?$/, '')

View File

@ -1,13 +1,13 @@
describe 'on the "build" state', ->
beforeEach ->
app 'travis-ci/travis-core/builds/1'
app '/travis-ci/travis-core/builds/1'
console.log 'wait for repos'
waitFor reposRendered
runs ->
console.log 'wait for build'
waitFor buildRendered
afterEach ->
window.history.pushState({}, null, '/spec.html')
it 'displays the expected stuff', ->
listsRepos [
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
@ -52,14 +52,11 @@ describe 'on the "build" state', ->
describe 'on the "current" state', ->
beforeEach ->
app 'travis-ci/travis-core'
app '/travis-ci/travis-core'
waitFor reposRendered
runs ->
waitFor buildRendered
afterEach ->
window.history.pushState({}, null, '/spec.html')
it 'correctly updates values on pusher build:started event', ->
payload =
build:
@ -72,8 +69,8 @@ describe 'on the "current" state', ->
finished_at: '2012-07-02T00:02:55Z'
event_type: 'push'
result: 1
commit_message: 'commit message 3'
commit: '1234567'
message: 'commit message 3'
commit: 'foo1234'
state: 'started'
repository:
id: 1
@ -81,10 +78,19 @@ describe 'on the "current" state', ->
last_build_id: 11
Em.run ->
Travis.app.receive 'build:started', payload
Travis.receive 'build:started', payload
waits(100)
runs ->
displaysSummaryBuildLink '/travis-ci/travis-core/builds/11', '3'
displaysSummary
type: 'build'
id: 11
repo: 'travis-ci/travis-core'
commit: 'foo1234'
branch: 'master'
compare: '0123456..1234567'
finishedAt: 'less than a minute ago'
duration: '55 sec'
message: 'commit message 3'

View File

@ -1,30 +1,12 @@
minispade.require 'app'
@reset = ->
Em.run ->
if Travis.app
if Travis.app.store
Travis.app.store.destroy()
Travis.app.destroy()
delete Travis.app
delete Travis.store
waits(500) # TODO not sure what we need to wait for here
$('#application').remove()
$('body').append( $('<div id="application"></div>') )
@app = (url) ->
reset()
Em.run ->
Travis.run(rootElement: $('#application'))
waitFor -> Travis.app
# TODO: so much waiting here, I'm sure we can minimize this
runs ->
url = "/#{url}" if url && !url.match(/^\//)
Travis.app.router.route(url)
waits 500
runs ->
foo = 'bar'
# TODO: this should wait till app is initialized, not some
# arbitrary amount of time
waits(50)
runs ->
Travis.reset()
Travis.__container__.lookup('router:main').handleURL(url)
_Date = Date
@Date = (date) ->

View File

@ -7,9 +7,9 @@ repos = [
]
builds = [
{ id: 1, repository_id: '1', commit_id: 1, job_ids: [1, 2, 3], number: 1, pull_request: false, config: { rvm: ['rbx', '1.9.3', 'jruby'] }, duration: 30, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:30Z', result: 0 },
{ id: 1, repository_id: '1', commit_id: 1, job_ids: [1, 2, 3], number: 1, pull_request: false, config: { rvm: ['rbx', '1.9.3', 'jruby'] }, duration: 30, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:30Z', state: 'passed' },
{ id: 2, repository_id: '1', commit_id: 2, job_ids: [4], number: 2, pull_request: false, config: { rvm: ['rbx'] } },
{ id: 3, repository_id: '2', commit_id: 3, job_ids: [5], number: 3, pull_request: false, config: { rvm: ['rbx'] }, duration: 30, started_at: '2012-07-02T00:01:00Z', finished_at: '2012-07-01T00:01:30Z', result: 1 },
{ id: 3, repository_id: '2', commit_id: 3, job_ids: [5], number: 3, pull_request: false, config: { rvm: ['rbx'] }, duration: 30, started_at: '2012-07-02T00:01:00Z', finished_at: '2012-07-01T00:01:30Z', state: 'failed' },
{ id: 4, repository_id: '3', commit_id: 4, job_ids: [6], number: 4, pull_request: false, config: { rvm: ['rbx'] }, started_at: '2012-07-02T00:02:00Z' },
]
@ -21,11 +21,11 @@ commits = [
]
jobs = [
{ id: 1, repository_id: 1, build_id: 1, commit_id: 1, log_id: 1, number: '1.1', config: { rvm: 'rbx' }, duration: 30, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:30Z', result: 0 }
{ id: 2, repository_id: 1, build_id: 1, commit_id: 1, log_id: 2, number: '1.2', config: { rvm: '1.9.3' }, duration: 40, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:40Z', result: 1 }
{ id: 1, repository_id: 1, build_id: 1, commit_id: 1, log_id: 1, number: '1.1', config: { rvm: 'rbx' }, duration: 30, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:30Z', state: 'passed' }
{ id: 2, repository_id: 1, build_id: 1, commit_id: 1, log_id: 2, number: '1.2', config: { rvm: '1.9.3' }, duration: 40, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:40Z', state: 'failed' }
{ id: 3, repository_id: 1, build_id: 1, commit_id: 1, log_id: 3, number: '1.3', config: { rvm: 'jruby' }, allow_failure: true }
{ id: 4, repository_id: 1, build_id: 2, commit_id: 2, log_id: 4, number: '2.1', config: { rvm: 'rbx' } }
{ id: 5, repository_id: 2, build_id: 3, commit_id: 3, log_id: 5, number: '3.1', config: { rvm: 'rbx' }, duration: 30, started_at: '2012-07-02T00:01:00Z', finished_at: '2012-07-02T00:01:30Z', result: 1 }
{ id: 5, repository_id: 2, build_id: 3, commit_id: 3, log_id: 5, number: '3.1', config: { rvm: 'rbx' }, duration: 30, started_at: '2012-07-02T00:01:00Z', finished_at: '2012-07-02T00:01:30Z', state: 'failed' }
{ id: 6, repository_id: 3, build_id: 4, commit_id: 4, log_id: 6, number: '4.1', config: { rvm: 'rbx' }, started_at: '2012-07-02T00:02:00Z' }
{ id: 7, repository_id: 1, build_id: 5, commit_id: 5, log_id: 7, number: '5.1', config: { rvm: 'rbx' }, state: 'created', queue: 'builds.common' }
{ id: 8, repository_id: 1, build_id: 5, commit_id: 5, log_id: 8, number: '5.2', config: { rvm: 'rbx' }, state: 'created', queue: 'builds.common' }

View File

@ -32,6 +32,12 @@ window.Travis = Em.Application.extend(Ember.Evented,
@set('auth', Travis.Auth.create(app: this, endpoint: Travis.config.api_endpoint))
reset: ->
@store.destroy()
@setup()
@_super.apply(this, arguments);
storeAfterSignInPath: (path) ->
@get('auth').storeAfterSignInPath(path)

View File

@ -13,6 +13,7 @@
<script>
window.testMode = true;
minispade.require('travis')
Travis.advanceReadiness()
</script>
<script src="/scripts/specs.js"></script>