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'))
|
||||
).property('data.config')
|
||||
|
||||
isPullRequest: (->
|
||||
@get('eventType') == 'pull_request'
|
||||
).property('eventType')
|
||||
|
||||
isMatrix: (->
|
||||
@get('data.job_ids.length') > 1
|
||||
).property('data.job_ids.length')
|
||||
|
|
|
@ -12,6 +12,15 @@ require 'travis/model'
|
|||
|
||||
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: (->
|
||||
id = @get('id')
|
||||
builds = Travis.Build.byRepoId id, event_type: 'push'
|
||||
|
@ -21,6 +30,10 @@ require 'travis/model'
|
|||
store: @get('store')
|
||||
|
||||
array.load(builds)
|
||||
|
||||
id = @get('id')
|
||||
array.observe(@get('allBuilds'), (build) -> build.get('repo.id') == id && !build.get('isPullRequest') )
|
||||
|
||||
array
|
||||
).property()
|
||||
|
||||
|
@ -34,6 +47,9 @@ require 'travis/model'
|
|||
|
||||
array.load(builds)
|
||||
|
||||
id = @get('id')
|
||||
array.observe(@get('allBuilds'), (build) -> @get('repositoryId') == id && build.get('isPullRequest') )
|
||||
|
||||
array
|
||||
).property()
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ Travis.Store = DS.Store.extend
|
|||
@loadIncomplete(Travis.Repo, json.repository || json.repo)
|
||||
else if type == Travis.Worker && json.worker.payload
|
||||
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
|
||||
@loadIncomplete(Travis.Job, job)
|
||||
@loadIncomplete(type, json[root])
|
||||
|
|
|
@ -19,6 +19,20 @@ Travis.ExpandableRecordArray = DS.RecordArray.extend
|
|||
|
||||
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) ->
|
||||
ids = @get 'content'
|
||||
id = record.get 'id'
|
||||
|
|
|
@ -41,45 +41,34 @@ describe 'events', ->
|
|||
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 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: 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 ->
|
||||
Travis.app.receive 'build:started', payload
|
||||
|
||||
waits(100)
|
||||
runs ->
|
||||
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', ->
|
||||
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() {
|
||||
beforeEach(function() {
|
||||
app('travis-ci/travis-core');
|
||||
|
|
|
@ -1 +1 @@
|
|||
12959e72
|
||||
0cebd87d
|
Loading…
Reference in New Issue
Block a user