Skip to content

Commit

Permalink
Merge pull request #198 from screwdriver-cd/fix
Browse files Browse the repository at this point in the history
fix: pipeline.getJobs don't sort by workflow if no workflow
  • Loading branch information
jithine authored Oct 17, 2017
2 parents fe163e0 + 1ebfe0b commit 87c679a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ class PipelineModel extends BaseModel {

return factory.list(listConfig)
.then((jobs) => {
// If archived is true, don't sort and just return jobs
if (listConfig.params.archived) {
// If using the new config or archived is true, don't sort and just return jobs
if (!Array.isArray(workflow) || !workflow.length || listConfig.params.archived) {
return jobs;
}

Expand Down
24 changes: 24 additions & 0 deletions test/lib/pipeline.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,30 @@ describe('Pipeline Model', () => {
assert.deepEqual(result, [blahJob, publishJob]);
});
});

it('Get jobs without sorting for new workflows', () => {
const config = {
params: {
archived: false
}
};
const expected = {
params: {
pipelineId: 'd398fb192747c9a0124e9e5b4e6e8e841cf8c71c',
archived: false
},
paginate
};
const jobList = [blahJob, publishJob];

pipeline.workflow = [];
jobFactoryMock.list.resolves(jobList);

return pipeline.getJobs(config).then((result) => {
assert.calledWith(jobFactoryMock.list, expected);
assert.deepEqual(result, [blahJob, publishJob]);
});
});
});

describe('get events', () => {
Expand Down

0 comments on commit 87c679a

Please sign in to comment.