travis-web/assets/scripts/spec/unit/build_spec.coffee
Piotr Sarnacki c7561ee13e Properly display matrix keys when build does not have all keys
When additional items are included into matrix via 'matrix.include' key
in .travis.yml they may contain config keys, which are not available on
build.

For example build can contain only 'rvm' key, but we may add the
following include:

    matrix:
      include:
        - rvm: '2.0.0'
          env: 'FOO=bar'

In such case, we need to take into account also keys from additional
job, not only from the build.

(closes #172)
2013-04-06 01:48:32 +02:00

47 lines
1.7 KiB
CoffeeScript

store = null
record = null
describe 'Travis.Build', ->
beforeEach ->
store = Travis.Store.create()
afterEach ->
store.destroy()
describe 'incomplete attributes', ->
beforeEach ->
store.loadIncomplete Travis.Build, { id: 1, state: 'started' }
record = store.find Travis.Build, 1
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('incomplete') ).toBeTruthy()
it 'loads the rest of the record if it\'s in finished state', ->
store.loadIncomplete Travis.Build, { id: 1, state: 'passed' }
record = store.find Travis.Build, 1
record.get('finishedAt')
waits 50
runs ->
expect( record.get('incomplete') ).toBeFalsy()
describe 'configKeys', ->
it 'takes into account all the jobs when getting config keys', ->
buildConfig = { rvm: ['1.9.3', '2.0.0'] }
store.load Travis.Build, { id: '1', job_ids: ['1', '2', '3'], config: buildConfig }, { id: '1' }
store.load Travis.Job, { id: '1', config: { rvm: '1.9.3', env: 'FOO=foo' } }, { id: '1' }
store.load Travis.Job, { id: '2', config: { rvm: '2.0.0', gemfile: 'Gemfile.1' } }, { id: '2' }
store.load Travis.Job, { id: '3', config: { rvm: '1.9.3', jdk: 'OpenJDK' } }, { id: '3' }
build = store.find(Travis.Build, '1')
expect( build.get('rawConfigKeys') ).toEqual( ['rvm', 'env', 'gemfile', 'jdk' ] )
expect( build.get('configKeys') ).toEqual( [ 'Job', 'Duration', 'Finished', 'Rvm', 'Env', 'Gemfile', 'Jdk' ] )