Fix build link when updating builds through pusher

This commit is contained in:
Piotr Sarnacki 2012-10-27 00:50:34 +02:00
parent 5eb3ab3b01
commit 94bff24f2c
8 changed files with 103 additions and 8 deletions

View File

@ -7,9 +7,9 @@
<dt>{{t builds.name}}</dt>
<dd class="number">
<span class="status"></span>
{{#if build.id}}
<a {{action showBuild repo build href=true}}>{{build.number}}</a>
{{/if}}
{{#with build}}
<a {{action showBuild repo this href=true}}>{{number}}</a>
{{/with}}
</dd>
<dt class="finished_at_label">{{t builds.finished_at}}</dt>
<dd class="finished_at timeago" {{bindAttr title="finishedAt"}}>{{formatTime build.finishedAt}}</dd>

View File

@ -55,8 +55,8 @@
currentItemBinding: 'build'
loading: (->
!@get('build.isComplete')
).property('build.isComplete')
!@get('build.isLoaded')
).property('build.isLoaded')
color: (->
Travis.Helpers.colorForResult(@get('build.result'))

View File

@ -49,3 +49,42 @@ describe 'on the "build" state', ->
jobs: [
{ color: '', id: 3, number: '1.3', repo: 'travis-ci/travis-core', finishedAt: '-', duration: '-', rvm: 'jruby' }
]
describe 'on the "current" state', ->
beforeEach ->
app 'travis-ci/travis-core'
waitFor reposRendered
runs ->
waitFor buildRendered
afterEach ->
window.history.pushState({}, null, '/spec.html')
it 'correctly updates values on pusher build:started event', ->
payload =
build:
id: 11
repository_id: 1
commit_id: 1
number: '3'
duration: 55
started_at: '2012-07-02T00:02:00Z'
finished_at: '2012-07-02T00:02:55Z'
event_type: 'push'
result: 1
commit_message: 'commit message 3'
commit: '1234567'
state: 'started'
repository:
id: 1
last_build_number: '3'
last_build_id: 11
Em.run ->
Travis.app.receive 'build:started', payload
waits(100)
runs ->
displaysSummaryBuildLink '/travis-ci/travis-core/builds/11', '3'

View File

@ -7,6 +7,11 @@
expect($("#tab_#{name}").hasClass('active')).toEqual !!tab.active
expect($("#tab_#{name}").hasClass('display-inline')).toEqual !tab.hidden if name in ['build', 'job']
@displaysSummaryBuildLink = (link, number) ->
element = $('#summary .number a')
expect( element.attr('href') ).toEqual link
expect( element.text().trim() ).toEqual "#{number}"
@displaysSummary = (data) ->
element = $('#summary .left:first-child dt:first-child')
expect(element.text()).toEqual $.camelize(data.type)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -7405,6 +7405,13 @@ return sinon;}.call(typeof window != 'undefined' && window || {}));
return _results;
};
this.displaysSummaryBuildLink = function(link, number) {
var element;
element = $('#summary .number a');
expect(element.attr('href')).toEqual(link);
return expect(element.text().trim()).toEqual("" + number);
};
this.displaysSummary = function(data) {
var element;
element = $('#summary .left:first-child dt:first-child');
@ -8176,6 +8183,50 @@ return sinon;}.call(typeof window != 'undefined' && window || {}));
});
});
describe('on the "current" state', function() {
beforeEach(function() {
app('travis-ci/travis-core');
waitFor(reposRendered);
return runs(function() {
return waitFor(buildRendered);
});
});
afterEach(function() {
return window.history.pushState({}, null, '/spec.html');
});
return it('correctly updates values on pusher build:started event', function() {
var payload;
payload = {
build: {
id: 11,
repository_id: 1,
commit_id: 1,
number: '3',
duration: 55,
started_at: '2012-07-02T00:02:00Z',
finished_at: '2012-07-02T00:02:55Z',
event_type: 'push',
result: 1,
commit_message: 'commit message 3',
commit: '1234567',
state: 'started'
},
repository: {
id: 1,
last_build_number: '3',
last_build_id: 11
}
};
Em.run(function() {
return Travis.app.receive('build:started', payload);
});
waits(100);
return runs(function() {
return displaysSummaryBuildLink('/travis-ci/travis-core/builds/11', '3');
});
});
});
}).call(this);
(function() {

View File

@ -1 +1 @@
0cebd87d
8c50af2e