fix error handling for log

This commit is contained in:
Lisa P 2016-02-25 17:15:45 +01:00 committed by Piotr Sarnacki
parent 0dc7e0e045
commit de26ed2091
5 changed files with 36 additions and 6 deletions

View File

@ -2,6 +2,7 @@ import Ember from 'ember';
export default Ember.Component.extend({
logBinding: 'job.log',
classNames: ['job-log'],
didReceiveAttrs: function(options) {
this._super(...arguments);
@ -25,7 +26,10 @@ export default Ember.Component.extend({
},
setupLog(job) {
job.get('log').fetch();
this.set('error', false);
job.get('log').fetch().then(function() { }, () => {
this.set('error', true);
});
job.subscribe();
}
});

View File

@ -50,7 +50,7 @@ export default function() {
if(log) {
return { log: { parts: [{ id: log.id, number: 1, content: log.content}] }};
} else {
new Mirage.Response(404, {}, {});
return new Mirage.Response(404, {}, {});
}
});

View File

@ -1,5 +1,9 @@
{{#if log.isLoaded}}
{{log-content job=job log=log}}
{{#if error}}
<p class="notice">There was an error while trying to fetch the log.</p>
{{else}}
{{loading-indicator}}
{{#if log.isLoaded}}
{{log-content job=job log=log}}
{{else}}
{{loading-indicator}}
{{/if}}
{{/if}}

View File

@ -25,3 +25,24 @@ test('visiting job-view', function(assert) {
assert.equal(jobPage.log, 'Hello log');
});
});
test('handling log error', function(assert) {
let repo = server.create('repository', {slug: 'travis-ci/travis-web'});
let branch = server.create('branch', {});
let commit = server.create('commit', {author_email: 'mrt@travis-ci.org', author_name: 'Mr T', committer_email: 'mrt@travis-ci.org', committer_name: 'Mr T', branch: 'acceptance-tests', message: 'This is a message', branch_is_default: true});
let build = server.create('build', {repository_id: repo.id, state: 'passed', commit_id: commit.id});
let job = server.create('job', {number: '1234.1', reposiptoy_id: repo.id, state: 'passed', build_id: build.id, commit_id: commit.id});
visit('/travis-ci/travis-web/jobs/'+ job.id);
andThen(function() {
assert.equal(jobPage.branch, 'acceptance-tests');
assert.equal(jobPage.message, 'acceptance-tests This is a message');
assert.equal(jobPage.state, '#1234.1 passed');
assert.equal(jobPage.author, 'Mr T authored and committed');
assert.equal(jobPage.logError, 'There was an error while trying to fetch the log.');
});
});

View File

@ -9,5 +9,6 @@ export default PageObject.create({
message: text('.build-title'),
state: text('.build-status'),
author: text('.commit-author'),
log: text('#log')
log: text('#log'),
logError: text('.job-log .notice')
});