Merge "Fix for wrong JSON format on OSTF tab"

This commit is contained in:
Jenkins 2015-06-19 12:59:25 +00:00 committed by Gerrit Code Review
commit d1bc5d5aed
1 changed files with 36 additions and 29 deletions

View File

@ -141,38 +141,45 @@ function($, _, i18n, Backbone, React, models, utils, componentMixins, controls)
runTests: function() {
var testruns = new models.TestRuns(),
oldTestruns = new models.TestRuns(),
selectedTests = this.props.tests.where({checked: true});
testsetIds = this.props.testsets.pluck('id');
this.setState({actionInProgress: true});
_.each(selectedTests, function(test) {
var testsetId = test.get('testset'),
testrunConfig = {tests: _.pluck(selectedTests, 'id')},
addCredentials = _.bind(function(obj) {
obj.ostf_os_access_creds = {
ostf_os_username: this.state.credentials.user,
ostf_os_tenant_name: this.state.credentials.tenant,
ostf_os_password: this.state.credentials.password
};
return obj;
}, this);
if (this.props.testruns.where({testset: testsetId}).length) {
_.each(this.props.testruns.where({testset: testsetId}), function(testrun) {
_.extend(testrunConfig, addCredentials({
id: testrun.id,
status: 'restarted'
}));
oldTestruns.add(new models.TestRun(testrunConfig));
}, this);
} else {
_.extend(testrunConfig, {
testset: testsetId,
metadata: addCredentials({
config: {},
cluster_id: this.props.cluster.id
})
});
testruns.add(new models.TestRun(testrunConfig));
_.each(testsetIds, function(testsetId) {
var testsToRun = _.pluck(this.props.tests.where({
testset: testsetId,
checked: true
}), 'id');
if (testsToRun.length) {
var testrunConfig = {tests: testsToRun},
addCredentials = _.bind(function(obj) {
obj.ostf_os_access_creds = {
ostf_os_username: this.state.credentials.user,
ostf_os_tenant_name: this.state.credentials.tenant,
ostf_os_password: this.state.credentials.password
};
return obj;
}, this);
if (this.props.testruns.where({testset: testsetId}).length) {
_.each(this.props.testruns.where({testset: testsetId}), function(testrun) {
_.extend(testrunConfig, addCredentials({
id: testrun.id,
status: 'restarted'
}));
oldTestruns.add(new models.TestRun(testrunConfig));
}, this);
} else {
_.extend(testrunConfig, {
testset: testsetId,
metadata: addCredentials({
config: {},
cluster_id: this.props.cluster.id
})
});
testruns.add(new models.TestRun(testrunConfig));
}
}
}, this);
var requests = [];
if (testruns.length) {
requests.push(Backbone.sync('create', testruns));