Fix adding builds to a build list on pusher event
This commit is contained in:
parent
95e9c7a17d
commit
3f0babcf55
|
@ -22,6 +22,10 @@ require 'travis/model'
|
||||||
Travis.Helpers.compact(@get('data.config'))
|
Travis.Helpers.compact(@get('data.config'))
|
||||||
).property('data.config')
|
).property('data.config')
|
||||||
|
|
||||||
|
isPullRequest: (->
|
||||||
|
@get('eventType') == 'pull_request'
|
||||||
|
).property('eventType')
|
||||||
|
|
||||||
isMatrix: (->
|
isMatrix: (->
|
||||||
@get('data.job_ids.length') > 1
|
@get('data.job_ids.length') > 1
|
||||||
).property('data.job_ids.length')
|
).property('data.job_ids.length')
|
||||||
|
|
|
@ -12,6 +12,15 @@ require 'travis/model'
|
||||||
|
|
||||||
lastBuild: DS.belongsTo('Travis.Build')
|
lastBuild: DS.belongsTo('Travis.Build')
|
||||||
|
|
||||||
|
allBuilds: (->
|
||||||
|
allBuilds = DS.RecordArray.create
|
||||||
|
type: Travis.Build
|
||||||
|
content: Ember.A([])
|
||||||
|
store: @get('store')
|
||||||
|
@get('store').registerRecordArray(allBuilds, Travis.Build);
|
||||||
|
allBuilds
|
||||||
|
).property()
|
||||||
|
|
||||||
builds: (->
|
builds: (->
|
||||||
id = @get('id')
|
id = @get('id')
|
||||||
builds = Travis.Build.byRepoId id, event_type: 'push'
|
builds = Travis.Build.byRepoId id, event_type: 'push'
|
||||||
|
@ -21,6 +30,10 @@ require 'travis/model'
|
||||||
store: @get('store')
|
store: @get('store')
|
||||||
|
|
||||||
array.load(builds)
|
array.load(builds)
|
||||||
|
|
||||||
|
id = @get('id')
|
||||||
|
array.observe(@get('allBuilds'), (build) -> build.get('repo.id') == id && !build.get('isPullRequest') )
|
||||||
|
|
||||||
array
|
array
|
||||||
).property()
|
).property()
|
||||||
|
|
||||||
|
@ -34,6 +47,9 @@ require 'travis/model'
|
||||||
|
|
||||||
array.load(builds)
|
array.load(builds)
|
||||||
|
|
||||||
|
id = @get('id')
|
||||||
|
array.observe(@get('allBuilds'), (build) -> @get('repositoryId') == id && build.get('isPullRequest') )
|
||||||
|
|
||||||
array
|
array
|
||||||
).property()
|
).property()
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ Travis.Store = DS.Store.extend
|
||||||
@loadIncomplete(Travis.Repo, json.repository || json.repo)
|
@loadIncomplete(Travis.Repo, json.repository || json.repo)
|
||||||
else if type == Travis.Worker && json.worker.payload
|
else if type == Travis.Worker && json.worker.payload
|
||||||
if repo = (json.worker.payload.repo || json.worker.payload.repository)
|
if repo = (json.worker.payload.repo || json.worker.payload.repository)
|
||||||
@loadIncomplete(Travis.Repo, repo)
|
@loadIncomplete(Travis.Repo, repo, skipIfExists: true)
|
||||||
if job = json.worker.payload.job
|
if job = json.worker.payload.job
|
||||||
@loadIncomplete(Travis.Job, job)
|
@loadIncomplete(Travis.Job, job)
|
||||||
@loadIncomplete(type, json[root])
|
@loadIncomplete(type, json[root])
|
||||||
|
|
|
@ -19,6 +19,20 @@ Travis.ExpandableRecordArray = DS.RecordArray.extend
|
||||||
|
|
||||||
array.addObserver 'isLoaded', observer
|
array.addObserver 'isLoaded', observer
|
||||||
|
|
||||||
|
observe: (collection, filterWith) ->
|
||||||
|
@set 'filterWith', filterWith
|
||||||
|
collection.addArrayObserver this,
|
||||||
|
willChange: 'observedArrayWillChange'
|
||||||
|
didChange: 'observedArraydidChange'
|
||||||
|
|
||||||
|
observedArrayWillChange: (->)
|
||||||
|
observedArraydidChange: (array, index, removedCount, addedCount) ->
|
||||||
|
addedObjects = array.slice index, index + addedCount
|
||||||
|
for object in addedObjects
|
||||||
|
console.log 'observedArraydidChange', object, object.toString(), object.get('repo.id'), object.get('id'), object.get('number')
|
||||||
|
if @get('filterWith').call this, object
|
||||||
|
@pushObject object
|
||||||
|
|
||||||
pushObject: (record) ->
|
pushObject: (record) ->
|
||||||
ids = @get 'content'
|
ids = @get 'content'
|
||||||
id = record.get 'id'
|
id = record.get 'id'
|
||||||
|
|
|
@ -41,45 +41,34 @@ describe 'events', ->
|
||||||
row: 2
|
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' } }
|
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', ->
|
describe 'an event adding a build', ->
|
||||||
# beforeEach ->
|
beforeEach ->
|
||||||
# app 'travis-ci/travis-core/builds'
|
app 'travis-ci/travis-core/builds'
|
||||||
# waitFor buildsRendered
|
waitFor buildsRendered
|
||||||
#
|
|
||||||
# it 'adds a build to the builds list', ->
|
it 'adds a build to the builds list', ->
|
||||||
# payload =
|
payload =
|
||||||
# build:
|
build:
|
||||||
# id: 11
|
id: 11
|
||||||
# repository_id: 1
|
repository_id: 1
|
||||||
# commit_id: 11
|
commit_id: 1
|
||||||
# number: '3'
|
number: '3'
|
||||||
# duration: 55
|
duration: 55
|
||||||
# started_at: '2012-07-02T00:02:00Z'
|
started_at: '2012-07-02T00:02:00Z'
|
||||||
# finished_at: '2012-07-02T00:02:55Z'
|
finished_at: '2012-07-02T00:02:55Z'
|
||||||
# event_type: 'push'
|
event_type: 'push'
|
||||||
# result: 1
|
result: 1
|
||||||
# commit:
|
commit_message: 'commit message 3'
|
||||||
# id: 11
|
commit: '1234567'
|
||||||
# sha: '1234567'
|
|
||||||
# branch: 'master'
|
Em.run ->
|
||||||
# message: 'commit message 3'
|
Travis.app.receive 'build:started', payload
|
||||||
#
|
|
||||||
#
|
waits(100)
|
||||||
# $.mockjax
|
runs ->
|
||||||
# url: '/builds/11'
|
listsBuild
|
||||||
# responseTime: 0
|
row: 3
|
||||||
# responseText: payload
|
item: { id: 11, slug: 'travis-ci/travis-core', number: '3', sha: '1234567', branch: 'master', message: 'commit message 1', finishedAt: 'less than a minute ago', duration: '55 sec', color: 'red' }
|
||||||
#
|
|
||||||
# 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', ->
|
describe 'an event adding a job', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -8431,6 +8431,50 @@ return sinon;}.call(typeof window != 'undefined' && window || {}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
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() {
|
||||||
|
var payload;
|
||||||
|
payload = {
|
||||||
|
build: {
|
||||||
|
id: 11,
|
||||||
|
repository_id: 1,
|
||||||
|
commit_id: 1,
|
||||||
|
number: '3',
|
||||||
|
duration: 55,
|
||||||
|
started_at: '2012-07-02T00:02:00Z',
|
||||||
|
finished_at: '2012-07-02T00:02:55Z',
|
||||||
|
event_type: 'push',
|
||||||
|
result: 1,
|
||||||
|
commit_message: 'commit message 3',
|
||||||
|
commit: '1234567'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Em.run(function() {
|
||||||
|
return Travis.app.receive('build:started', payload);
|
||||||
|
});
|
||||||
|
waits(100);
|
||||||
|
return runs(function() {
|
||||||
|
return listsBuild({
|
||||||
|
row: 3,
|
||||||
|
item: {
|
||||||
|
id: 11,
|
||||||
|
slug: 'travis-ci/travis-core',
|
||||||
|
number: '3',
|
||||||
|
sha: '1234567',
|
||||||
|
branch: 'master',
|
||||||
|
message: 'commit message 1',
|
||||||
|
finishedAt: 'less than a minute ago',
|
||||||
|
duration: '55 sec',
|
||||||
|
color: 'red'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
describe('an event adding a job', function() {
|
describe('an event adding a job', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
app('travis-ci/travis-core');
|
app('travis-ci/travis-core');
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
12959e72
|
0cebd87d
|
Loading…
Reference in New Issue
Block a user