Don't require some of the attributes for incomplete records
When build or job is not finished, we don't need to load the record because of them, they will be loaded when 'finished' events come in.
This commit is contained in:
parent
eef8e55cfe
commit
dff93c93fe
|
@ -53,6 +53,17 @@ require 'travis/model'
|
|||
Travis.ajax.post '/requests', build_id: @get('id')
|
||||
)
|
||||
|
||||
isAttributeLoaded: (key) ->
|
||||
if ['_duration', 'finishedAt', 'result'].contains(key) && !@get('finished')
|
||||
return true
|
||||
else
|
||||
@_super(key)
|
||||
|
||||
finished: (->
|
||||
@get('state') == 'finished'
|
||||
).property('state')
|
||||
|
||||
|
||||
@Travis.Build.reopenClass
|
||||
byRepoId: (id, parameters) ->
|
||||
@find($.extend(parameters || {}, repository_id: id))
|
||||
|
|
|
@ -52,9 +52,20 @@ require 'travis/model'
|
|||
Travis.app.pusher.subscribe "job-#{id}"
|
||||
|
||||
onStateChange: (->
|
||||
Travis.app.pusher.unsubscribe "job-#{@get('id')}" if @get('state') == 'finished'
|
||||
if @get('state') == 'finished' && Travis.app
|
||||
Travis.app.pusher.unsubscribe "job-#{@get('id')}"
|
||||
).observes('state')
|
||||
|
||||
isAttributeLoaded: (key) ->
|
||||
if ['_duration', 'finishedAt', 'result'].contains(key) && !@get('finished')
|
||||
return true
|
||||
else
|
||||
@_super(key)
|
||||
|
||||
finished: (->
|
||||
@get('state') == 'finished'
|
||||
).property('state')
|
||||
|
||||
@Travis.Job.reopenClass
|
||||
queued: (queue) ->
|
||||
@find()
|
||||
|
|
30
assets/scripts/spec/unit/build_spec.coffee
Normal file
30
assets/scripts/spec/unit/build_spec.coffee
Normal file
|
@ -0,0 +1,30 @@
|
|||
store = null
|
||||
record = null
|
||||
|
||||
describe 'Travis.Build', ->
|
||||
beforeEach ->
|
||||
store = Travis.Store.create()
|
||||
|
||||
afterEach ->
|
||||
store.destroy()
|
||||
|
||||
describe 'incomplete attributes', ->
|
||||
beforeEach ->
|
||||
record = store.loadIncomplete Travis.Build, { id: 1, state: 'started' }
|
||||
|
||||
it 'does not load record on duration, finishedAt and result if job is not in finished state', ->
|
||||
record.get('_duration')
|
||||
record.get('finishedAt')
|
||||
record.get('result')
|
||||
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('complete') ).toBeFalsy()
|
||||
|
||||
it 'loads the rest of the record if it\'s in finished state', ->
|
||||
record = store.loadIncomplete Travis.Build, { id: 1, state: 'finished' }
|
||||
record.get('finishedAt')
|
||||
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('complete') ).toBeTruthy()
|
|
@ -1,4 +1,5 @@
|
|||
store = null
|
||||
record = null
|
||||
|
||||
describe 'Travis.Job', ->
|
||||
beforeEach ->
|
||||
|
@ -7,6 +8,28 @@ describe 'Travis.Job', ->
|
|||
afterEach ->
|
||||
store.destroy()
|
||||
|
||||
describe 'incomplete attributes', ->
|
||||
beforeEach ->
|
||||
record = store.loadIncomplete Travis.Job, { id: 1, state: 'started' }
|
||||
|
||||
it 'does not load record on duration, finishedAt and result if job is not in finished state', ->
|
||||
record.get('_duration')
|
||||
record.get('finishedAt')
|
||||
record.get('result')
|
||||
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('complete') ).toBeFalsy()
|
||||
|
||||
it 'loads the rest of the record if it\'s in finished state', ->
|
||||
record = store.loadIncomplete Travis.Job, { id: 1, state: 'finished' }
|
||||
record.get('finishedAt')
|
||||
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('complete') ).toBeTruthy()
|
||||
|
||||
|
||||
describe 'with different number of config keys in sibling jobs', ->
|
||||
beforeEach ->
|
||||
buildAttrs =
|
||||
|
|
Loading…
Reference in New Issue
Block a user