
Specs needed to be updated to handle new way of receiving methods. What's more they revealed a subtle bug that was present after changing merge function to fetch record if it's not present. After calling merge, store calls method to update associations. This may be not possible if clientId for new record is not correctly set.
193 lines
4.7 KiB
CoffeeScript
193 lines
4.7 KiB
CoffeeScript
describe 'events', ->
|
|
afterEach ->
|
|
window.history.pushState({}, null, '/spec.html')
|
|
|
|
describe 'an event adding a repository', ->
|
|
beforeEach ->
|
|
app 'travis-ci/travis-core'
|
|
waitFor jobsRendered
|
|
|
|
it 'adds a repository to the list', ->
|
|
waitFor reposRendered
|
|
|
|
runs ->
|
|
payload =
|
|
repository:
|
|
id: 10
|
|
slug: 'travis-ci/travis-support'
|
|
last_build_id: 10
|
|
last_build_number: 10
|
|
last_build_started_at: '2012-07-02T00:01:00Z'
|
|
last_build_finished_at: '2012-07-02T00:02:30Z'
|
|
build:
|
|
id: 10
|
|
repository_id: 10
|
|
|
|
$.mockjax
|
|
url: '/builds/10'
|
|
responseTime: 0
|
|
responseText: payload
|
|
|
|
Em.run ->
|
|
Travis.app.receive 'build:started',
|
|
build:
|
|
id: 10
|
|
|
|
waits(100)
|
|
runs ->
|
|
listsRepo
|
|
row: 2
|
|
item: { slug: 'travis-ci/travis-support', build: { number: 4, url: '/travis-ci/travis-support/builds/10', duration: '1 min 30 sec', finishedAt: 'less than a minute ago' } }
|
|
|
|
describe 'an event adding a build', ->
|
|
beforeEach ->
|
|
app 'travis-ci/travis-core/builds'
|
|
waitFor buildsRendered
|
|
|
|
it 'adds a build to the builds list', ->
|
|
payload =
|
|
build:
|
|
id: 11
|
|
repository_id: 1
|
|
commit_id: 11
|
|
number: '3'
|
|
duration: 55
|
|
started_at: '2012-07-02T00:02:00Z'
|
|
finished_at: '2012-07-02T00:02:55Z'
|
|
event_type: 'push'
|
|
result: 1
|
|
commit:
|
|
id: 11
|
|
sha: '1234567'
|
|
branch: 'master'
|
|
message: 'commit message 3'
|
|
|
|
|
|
$.mockjax
|
|
url: '/builds/11'
|
|
responseTime: 0
|
|
responseText: payload
|
|
|
|
Em.run ->
|
|
Travis.app.receive 'build:started',
|
|
build:
|
|
id: 11
|
|
|
|
waits(100)
|
|
runs ->
|
|
listsBuild
|
|
row: 3
|
|
item: { id: 11, slug: 'travis-ci/travis-core', number: '3', sha: '1234567', branch: 'master', message: 'commit message 3', finishedAt: 'less than a minute ago', duration: '55 sec', color: 'red' }
|
|
|
|
describe 'an event adding a job', ->
|
|
beforeEach ->
|
|
app 'travis-ci/travis-core'
|
|
waitFor jobsRendered
|
|
runs ->
|
|
waitFor queuesRendered
|
|
|
|
it 'adds a job to the jobs matrix', ->
|
|
payload =
|
|
job:
|
|
id: 15
|
|
repository_id: 1
|
|
build_id: 1
|
|
commit_id: 1
|
|
log_id: 1
|
|
number: '1.4'
|
|
duration: 55
|
|
started_at: '2012-07-02T00:02:00Z'
|
|
finished_at: '2012-07-02T00:02:55Z'
|
|
config: { rvm: 'jruby' }
|
|
|
|
$.mockjax
|
|
url: '/jobs/15'
|
|
responseTime: 0
|
|
responseText: payload
|
|
|
|
Em.run ->
|
|
Travis.app.receive 'job:started',
|
|
job:
|
|
id: 15
|
|
build_id: 1
|
|
|
|
waits(100)
|
|
runs ->
|
|
listsJob
|
|
table: $('#jobs')
|
|
row: 3
|
|
item: { id: 15, number: '1.4', repo: 'travis-ci/travis-core', finishedAt: 'less than a minute ago', duration: '55 sec', rvm: 'jruby' }
|
|
|
|
it 'adds a job to the jobs queue', ->
|
|
payload =
|
|
job:
|
|
id: 12
|
|
repository_id: 1
|
|
number: '1.4'
|
|
queue: 'common'
|
|
|
|
$.mockjax
|
|
url: '/jobs/12'
|
|
responseTime: 0
|
|
responseText: payload
|
|
|
|
Em.run ->
|
|
Travis.app.receive 'job:started',
|
|
job:
|
|
id: 12
|
|
|
|
waits(100)
|
|
runs ->
|
|
listsQueuedJob
|
|
name: 'common'
|
|
row: 3
|
|
item: { number: '1.4', repo: 'travis-ci/travis-core' }
|
|
|
|
it 'updates only keys that are available', ->
|
|
Em.run ->
|
|
Travis.app.receive 'job:started',
|
|
job:
|
|
id: 1
|
|
build_id: 1
|
|
|
|
waits(100)
|
|
runs ->
|
|
listsJob
|
|
table: $('#jobs')
|
|
row: 1
|
|
item: { id: 1, number: '1.1', repo: 'travis-ci/travis-core', finishedAt: '3 minutes ago', duration: '30 sec', rvm: 'rbx' }
|
|
|
|
describe 'an event adding a worker', ->
|
|
beforeEach ->
|
|
app ''
|
|
waitFor workersRendered
|
|
|
|
it 'adds a worker to the workers list', ->
|
|
payload =
|
|
worker:
|
|
id: 10
|
|
host: 'worker.travis-ci.org'
|
|
name: 'ruby-3'
|
|
state: 'ready'
|
|
|
|
$.mockjax
|
|
url: '/workers/10'
|
|
responseTime: 0
|
|
responseText: payload
|
|
|
|
Em.run ->
|
|
Travis.app.receive 'worker:created',
|
|
worker:
|
|
id: 10
|
|
name: 'ruby-3'
|
|
host: 'worker.travis-ci.org'
|
|
state: 'ready'
|
|
|
|
waits(100)
|
|
runs ->
|
|
listsWorker
|
|
group: 'worker.travis-ci.org'
|
|
row: 3
|
|
item: { name: 'ruby-3', state: 'ready' }
|
|
|