Skip to content

Commit

Permalink
Merge pull request #60 from screwdriver-cd/noStartTime
Browse files Browse the repository at this point in the history
Fix error calculating buildDuration when there is no startTime
  • Loading branch information
petey authored Sep 30, 2016
2 parents 9154148 + 7280fb9 commit e4dd6be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/build/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default DS.Model.extend({
}),
buildDuration: Ember.computed('startTime', 'endTime', {
get() {
if (!this.get('endTime')) {
if (!this.get('endTime') || !this.get('startTime')) {
return humanizeDuration(0);
}

Expand Down
6 changes: 6 additions & 0 deletions tests/unit/build/model-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ test('it calculates buildDuration', function (assert) {
});

Ember.run(() => {
// valid duration
assert.equal(model.get('buildDuration'), '10 seconds');
// no end time, so duration is 0
model.set('endTime', null);
assert.equal(model.get('buildDuration'), '0 seconds');
// no start time, so duration is 0
model.set('endTime', new Date(1472244592531));
model.set('startTime', null);
assert.equal(model.get('buildDuration'), '0 seconds');
});
});

Expand Down

0 comments on commit e4dd6be

Please sign in to comment.