Fix jobs table when jobs have different config keys
If we have 2 jobs within 1 build, with such config values: { rvm: 'jruby-head', jdk: 'oraclejdk7' } { rvm: '1.9.3', jdk: null } We should return jdk in configValues for second build, even if it's not present. Otherwise table rows may be missing. (closes #28)
This commit is contained in:
parent
f790a809ff
commit
af00392d15
|
@ -34,8 +34,11 @@ require 'travis/model'
|
||||||
).property('log.workerName')
|
).property('log.workerName')
|
||||||
|
|
||||||
configValues: (->
|
configValues: (->
|
||||||
if config = @get('config')
|
config = @get('config')
|
||||||
$.values($.only.apply(config, Travis.CONFIG_KEYS))
|
buildConfig = @get('build.config')
|
||||||
|
if config && buildConfig
|
||||||
|
keys = $.intersect($.keys(buildConfig), Travis.CONFIG_KEYS)
|
||||||
|
keys.map (key) -> config[key]
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
).property('config')
|
).property('config')
|
||||||
|
|
44
assets/scripts/spec/unit/job_spec.coffee
Normal file
44
assets/scripts/spec/unit/job_spec.coffee
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
store = null
|
||||||
|
|
||||||
|
describe 'Travis.Job', ->
|
||||||
|
beforeEach ->
|
||||||
|
store = Travis.Store.create()
|
||||||
|
|
||||||
|
afterEach ->
|
||||||
|
store.destroy()
|
||||||
|
|
||||||
|
describe 'with different number of config keys in sibling jobs', ->
|
||||||
|
beforeEach ->
|
||||||
|
buildAttrs =
|
||||||
|
id: 1
|
||||||
|
job_ids: [1, 2]
|
||||||
|
config:
|
||||||
|
jdk: ['oraclejdk7']
|
||||||
|
rvm: ['jruby-head']
|
||||||
|
|
||||||
|
store.load Travis.Build, 1, buildAttrs
|
||||||
|
|
||||||
|
jobAttrs =
|
||||||
|
id: 1
|
||||||
|
build_id: 1
|
||||||
|
config:
|
||||||
|
jdk: 'oraclejdk7'
|
||||||
|
rvm: 'jruby-head'
|
||||||
|
|
||||||
|
store.load Travis.Job, 1, jobAttrs
|
||||||
|
|
||||||
|
jobAttrs =
|
||||||
|
id: 2
|
||||||
|
build_id: 1
|
||||||
|
config:
|
||||||
|
jdk: null
|
||||||
|
rvm: 'jruby-head'
|
||||||
|
|
||||||
|
store.load Travis.Job, 2, jobAttrs
|
||||||
|
|
||||||
|
it 'returns config values for all keys available on build', ->
|
||||||
|
job1 = store.find Travis.Job, 1
|
||||||
|
job2 = store.find Travis.Job, 2
|
||||||
|
|
||||||
|
expect( job1.get('configValues') ).toEqual ['oraclejdk7', 'jruby-head']
|
||||||
|
expect( job2.get('configValues') ).toEqual [undefined, 'jruby-head']
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -8964,3 +8964,57 @@ return sinon;}.call(typeof window != 'undefined' && window || {}));
|
||||||
});
|
});
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
(function() {
|
||||||
|
var store;
|
||||||
|
|
||||||
|
store = null;
|
||||||
|
|
||||||
|
describe('Travis.Job', function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
return store = Travis.Store.create();
|
||||||
|
});
|
||||||
|
afterEach(function() {
|
||||||
|
return store.destroy();
|
||||||
|
});
|
||||||
|
return describe('with different number of config keys in sibling jobs', function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
var buildAttrs, jobAttrs;
|
||||||
|
buildAttrs = {
|
||||||
|
id: 1,
|
||||||
|
job_ids: [1, 2],
|
||||||
|
config: {
|
||||||
|
jdk: ['oraclejdk7'],
|
||||||
|
rvm: ['jruby-head']
|
||||||
|
}
|
||||||
|
};
|
||||||
|
store.load(Travis.Build, 1, buildAttrs);
|
||||||
|
jobAttrs = {
|
||||||
|
id: 1,
|
||||||
|
build_id: 1,
|
||||||
|
config: {
|
||||||
|
jdk: 'oraclejdk7',
|
||||||
|
rvm: 'jruby-head'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
store.load(Travis.Job, 1, jobAttrs);
|
||||||
|
jobAttrs = {
|
||||||
|
id: 2,
|
||||||
|
build_id: 1,
|
||||||
|
config: {
|
||||||
|
jdk: null,
|
||||||
|
rvm: 'jruby-head'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return store.load(Travis.Job, 2, jobAttrs);
|
||||||
|
});
|
||||||
|
return it('returns config values for all keys available on build', function() {
|
||||||
|
var job1, job2;
|
||||||
|
job1 = store.find(Travis.Job, 1);
|
||||||
|
job2 = store.find(Travis.Job, 2);
|
||||||
|
expect(job1.get('configValues')).toEqual(['oraclejdk7', 'jruby-head']);
|
||||||
|
return expect(job2.get('configValues')).toEqual([void 0, 'jruby-head']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}).call(this);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1 +1 @@
|
||||||
8a51b157
|
21ef8a81
|
Loading…
Reference in New Issue
Block a user