Fix specs and a bug that they've catched
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.
This commit is contained in:
parent
f7422e15c7
commit
8b25160a62
assets/javascripts
public/javascripts
|
@ -15,15 +15,17 @@ require 'travis/model'
|
|||
).property('name')
|
||||
|
||||
display: (->
|
||||
name = @get('name').replace('travis-', '')
|
||||
name = @get('name')
|
||||
state = @get('state')
|
||||
payload = @get('payload')
|
||||
if name
|
||||
name = name.replace('travis-', '')
|
||||
if state == 'working' && payload != undefined
|
||||
repo = if payload.repository then $.truncate(payload.repository.slug, 18) else undefined
|
||||
number = if payload.build and payload.build.number then ' #' + payload.build.number else ''
|
||||
state = if repo then repo + number else state
|
||||
name + ': ' + state
|
||||
).property('state')
|
||||
).property('state', 'name', 'payload')
|
||||
|
||||
urlJob: (->
|
||||
"/#{@get('repository')}/jobs/#{@get('job_id')}" if @get('state') == 'working'
|
||||
|
|
|
@ -33,8 +33,9 @@ Travis.Store = DS.Store.extend
|
|||
# if event is triggered for a record
|
||||
# that's not yet available, just use find
|
||||
# to make a request to fetch it
|
||||
@find(type, id)
|
||||
clientId = @find(type, id).get('clientId')
|
||||
|
||||
if clientId
|
||||
DATA_PROXY.savedData = hash
|
||||
@updateRecordArrays(type, clientId, DATA_PROXY)
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@ describe 'events', ->
|
|||
waitFor reposRendered
|
||||
|
||||
runs ->
|
||||
Em.run ->
|
||||
Travis.app.receive 'build',
|
||||
payload =
|
||||
repository:
|
||||
id: 10
|
||||
slug: 'travis-ci/travis-support'
|
||||
|
@ -24,6 +23,18 @@ describe 'events', ->
|
|||
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' } }
|
||||
|
@ -34,12 +45,11 @@ describe 'events', ->
|
|||
waitFor buildsRendered
|
||||
|
||||
it 'adds a build to the builds list', ->
|
||||
Em.run ->
|
||||
Travis.app.receive 'build',
|
||||
payload =
|
||||
build:
|
||||
id: 10
|
||||
id: 11
|
||||
repository_id: 1
|
||||
commit_id: 10
|
||||
commit_id: 11
|
||||
number: '3'
|
||||
duration: 55
|
||||
started_at: '2012-07-02T00:02:00Z'
|
||||
|
@ -47,14 +57,27 @@ describe 'events', ->
|
|||
event_type: 'push'
|
||||
result: 1
|
||||
commit:
|
||||
id: 10
|
||||
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: 10, 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' }
|
||||
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 ->
|
||||
|
@ -64,10 +87,9 @@ describe 'events', ->
|
|||
waitFor queuesRendered
|
||||
|
||||
it 'adds a job to the jobs matrix', ->
|
||||
Em.run ->
|
||||
Travis.app.receive 'job',
|
||||
payload =
|
||||
job:
|
||||
id: 10
|
||||
id: 15
|
||||
repository_id: 1
|
||||
build_id: 1
|
||||
commit_id: 1
|
||||
|
@ -78,20 +100,44 @@ describe 'events', ->
|
|||
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: 10, number: '1.4', repo: 'travis-ci/travis-core', finishedAt: 'less than a minute ago', duration: '55 sec', rvm: 'jruby' }
|
||||
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', ->
|
||||
Em.run ->
|
||||
Travis.app.receive 'job',
|
||||
payload =
|
||||
job:
|
||||
id: 10
|
||||
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
|
||||
|
@ -99,11 +145,13 @@ describe 'events', ->
|
|||
|
||||
it 'updates only keys that are available', ->
|
||||
Em.run ->
|
||||
Travis.app.receive 'job',
|
||||
Travis.app.receive 'job:started',
|
||||
job:
|
||||
id: 1
|
||||
build_id: 1
|
||||
|
||||
waits(100)
|
||||
runs ->
|
||||
listsJob
|
||||
table: $('#jobs')
|
||||
row: 1
|
||||
|
@ -115,14 +163,28 @@ describe 'events', ->
|
|||
waitFor workersRendered
|
||||
|
||||
it 'adds a worker to the workers list', ->
|
||||
Em.run ->
|
||||
Travis.app.receive 'worker',
|
||||
payload =
|
||||
worker:
|
||||
id: 10
|
||||
host: 'worker.travis-ci.org'
|
||||
name: 'ruby-3'
|
||||
state: 'ready'
|
||||
id: 10
|
||||
|
||||
$.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
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -316,8 +316,8 @@
|
|||
return it('adds a repository to the list', function() {
|
||||
waitFor(reposRendered);
|
||||
return runs(function() {
|
||||
Em.run(function() {
|
||||
return Travis.app.receive('build', {
|
||||
var payload;
|
||||
payload = {
|
||||
repository: {
|
||||
id: 10,
|
||||
slug: 'travis-ci/travis-support',
|
||||
|
@ -330,8 +330,21 @@
|
|||
id: 10,
|
||||
repository_id: 10
|
||||
}
|
||||
};
|
||||
$.mockjax({
|
||||
url: '/builds/10',
|
||||
responseTime: 0,
|
||||
responseText: payload
|
||||
});
|
||||
Em.run(function() {
|
||||
return Travis.app.receive('build:started', {
|
||||
build: {
|
||||
id: 10
|
||||
}
|
||||
});
|
||||
});
|
||||
waits(100);
|
||||
return runs(function() {
|
||||
return listsRepo({
|
||||
row: 2,
|
||||
item: {
|
||||
|
@ -347,18 +360,19 @@
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('an event adding a build', function() {
|
||||
beforeEach(function() {
|
||||
app('travis-ci/travis-core/builds');
|
||||
return waitFor(buildsRendered);
|
||||
});
|
||||
return it('adds a build to the builds list', function() {
|
||||
Em.run(function() {
|
||||
return Travis.app.receive('build', {
|
||||
var payload;
|
||||
payload = {
|
||||
build: {
|
||||
id: 10,
|
||||
id: 11,
|
||||
repository_id: 1,
|
||||
commit_id: 10,
|
||||
commit_id: 11,
|
||||
number: '3',
|
||||
duration: 55,
|
||||
started_at: '2012-07-02T00:02:00Z',
|
||||
|
@ -367,17 +381,30 @@
|
|||
result: 1
|
||||
},
|
||||
commit: {
|
||||
id: 10,
|
||||
id: 11,
|
||||
sha: '1234567',
|
||||
branch: 'master',
|
||||
message: 'commit message 3'
|
||||
}
|
||||
};
|
||||
$.mockjax({
|
||||
url: '/builds/11',
|
||||
responseTime: 0,
|
||||
responseText: payload
|
||||
});
|
||||
Em.run(function() {
|
||||
return Travis.app.receive('build:started', {
|
||||
build: {
|
||||
id: 11
|
||||
}
|
||||
});
|
||||
});
|
||||
waits(100);
|
||||
return runs(function() {
|
||||
return listsBuild({
|
||||
row: 3,
|
||||
item: {
|
||||
id: 10,
|
||||
id: 11,
|
||||
slug: 'travis-ci/travis-core',
|
||||
number: '3',
|
||||
sha: '1234567',
|
||||
|
@ -390,6 +417,7 @@
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('an event adding a job', function() {
|
||||
beforeEach(function() {
|
||||
app('travis-ci/travis-core');
|
||||
|
@ -399,10 +427,10 @@
|
|||
});
|
||||
});
|
||||
it('adds a job to the jobs matrix', function() {
|
||||
Em.run(function() {
|
||||
return Travis.app.receive('job', {
|
||||
var payload;
|
||||
payload = {
|
||||
job: {
|
||||
id: 10,
|
||||
id: 15,
|
||||
repository_id: 1,
|
||||
build_id: 1,
|
||||
commit_id: 1,
|
||||
|
@ -415,13 +443,27 @@
|
|||
rvm: 'jruby'
|
||||
}
|
||||
}
|
||||
};
|
||||
$.mockjax({
|
||||
url: '/jobs/15',
|
||||
responseTime: 0,
|
||||
responseText: payload
|
||||
});
|
||||
Em.run(function() {
|
||||
return Travis.app.receive('job:started', {
|
||||
job: {
|
||||
id: 15,
|
||||
build_id: 1
|
||||
}
|
||||
});
|
||||
});
|
||||
waits(100);
|
||||
return runs(function() {
|
||||
return listsJob({
|
||||
table: $('#jobs'),
|
||||
row: 3,
|
||||
item: {
|
||||
id: 10,
|
||||
id: 15,
|
||||
number: '1.4',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: 'less than a minute ago',
|
||||
|
@ -430,17 +472,31 @@
|
|||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('adds a job to the jobs queue', function() {
|
||||
Em.run(function() {
|
||||
return Travis.app.receive('job', {
|
||||
var payload;
|
||||
payload = {
|
||||
job: {
|
||||
id: 10,
|
||||
id: 12,
|
||||
repository_id: 1,
|
||||
number: '1.4',
|
||||
queue: 'common'
|
||||
}
|
||||
};
|
||||
$.mockjax({
|
||||
url: '/jobs/12',
|
||||
responseTime: 0,
|
||||
responseText: payload
|
||||
});
|
||||
Em.run(function() {
|
||||
return Travis.app.receive('job:started', {
|
||||
job: {
|
||||
id: 12
|
||||
}
|
||||
});
|
||||
});
|
||||
waits(100);
|
||||
return runs(function() {
|
||||
return listsQueuedJob({
|
||||
name: 'common',
|
||||
row: 3,
|
||||
|
@ -450,15 +506,18 @@
|
|||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
return it('updates only keys that are available', function() {
|
||||
Em.run(function() {
|
||||
return Travis.app.receive('job', {
|
||||
return Travis.app.receive('job:started', {
|
||||
job: {
|
||||
id: 1,
|
||||
build_id: 1
|
||||
}
|
||||
});
|
||||
});
|
||||
waits(100);
|
||||
return runs(function() {
|
||||
return listsJob({
|
||||
table: $('#jobs'),
|
||||
row: 1,
|
||||
|
@ -473,22 +532,39 @@
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
return describe('an event adding a worker', function() {
|
||||
beforeEach(function() {
|
||||
app('');
|
||||
return waitFor(workersRendered);
|
||||
});
|
||||
return it('adds a worker to the workers list', function() {
|
||||
Em.run(function() {
|
||||
return Travis.app.receive('worker', {
|
||||
var payload;
|
||||
payload = {
|
||||
worker: {
|
||||
id: 10,
|
||||
host: 'worker.travis-ci.org',
|
||||
name: 'ruby-3',
|
||||
state: 'ready',
|
||||
id: 10
|
||||
state: 'ready'
|
||||
}
|
||||
};
|
||||
$.mockjax({
|
||||
url: '/workers/10',
|
||||
responseTime: 0,
|
||||
responseText: payload
|
||||
});
|
||||
Em.run(function() {
|
||||
return Travis.app.receive('worker:created', {
|
||||
worker: {
|
||||
id: 10,
|
||||
name: 'ruby-3',
|
||||
host: 'worker.travis-ci.org',
|
||||
state: 'ready'
|
||||
}
|
||||
});
|
||||
});
|
||||
waits(100);
|
||||
return runs(function() {
|
||||
return listsWorker({
|
||||
group: 'worker.travis-ci.org',
|
||||
row: 3,
|
||||
|
@ -500,6 +576,7 @@
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
(function() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user