From 94bff24f2c1bc5e7c894e29e28f947666266096e Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sat, 27 Oct 2012 00:50:34 +0200 Subject: [PATCH] Fix build link when updating builds through pusher --- assets/scripts/app/templates/builds/show.hbs | 6 +-- assets/scripts/app/views/build.coffee | 4 +- assets/scripts/spec/build_spec.coffee | 39 ++++++++++++++ .../scripts/spec/support/expectations.coffee | 5 ++ public/scripts/app.js | 2 +- public/scripts/min/app.js | 2 +- public/scripts/specs.js | 51 +++++++++++++++++++ public/version | 2 +- 8 files changed, 103 insertions(+), 8 deletions(-) diff --git a/assets/scripts/app/templates/builds/show.hbs b/assets/scripts/app/templates/builds/show.hbs index a206d8bc..53a3a1ec 100644 --- a/assets/scripts/app/templates/builds/show.hbs +++ b/assets/scripts/app/templates/builds/show.hbs @@ -7,9 +7,9 @@
{{t builds.name}}
- {{#if build.id}} - {{build.number}} - {{/if}} + {{#with build}} + {{number}} + {{/with}}
{{t builds.finished_at}}
{{formatTime build.finishedAt}}
diff --git a/assets/scripts/app/views/build.coffee b/assets/scripts/app/views/build.coffee index a1ea3014..688bd4de 100644 --- a/assets/scripts/app/views/build.coffee +++ b/assets/scripts/app/views/build.coffee @@ -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')) diff --git a/assets/scripts/spec/build_spec.coffee b/assets/scripts/spec/build_spec.coffee index c854761f..d650cc58 100644 --- a/assets/scripts/spec/build_spec.coffee +++ b/assets/scripts/spec/build_spec.coffee @@ -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' + + diff --git a/assets/scripts/spec/support/expectations.coffee b/assets/scripts/spec/support/expectations.coffee index e4b7a6d1..6365fdc7 100644 --- a/assets/scripts/spec/support/expectations.coffee +++ b/assets/scripts/spec/support/expectations.coffee @@ -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) diff --git a/public/scripts/app.js b/public/scripts/app.js index 78e38393..f0416cc6 100644 --- a/public/scripts/app.js +++ b/public/scripts/app.js @@ -30753,4 +30753,4 @@ var _require=function(){function c(a,c){document.addEventListener?a.addEventList ++g&&setTimeout(c,0)})}}(); (function(){!window.WebSocket&&window.MozWebSocket&&(window.WebSocket=window.MozWebSocket);if(window.WebSocket)Pusher.Transport=window.WebSocket,Pusher.TransportType="native";var c=(document.location.protocol=="http:"?Pusher.cdn_http:Pusher.cdn_https)+Pusher.VERSION,a=[];window.JSON||a.push(c+"/json2"+Pusher.dependency_suffix+".js");if(!window.WebSocket)window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0,a.push(c+"/flashfallback"+Pusher.dependency_suffix+".js");var b=function(){return window.WebSocket?function(){Pusher.ready()}: function(){window.WebSocket?(Pusher.Transport=window.WebSocket,Pusher.TransportType="flash",window.WEB_SOCKET_SWF_LOCATION=c+"/WebSocketMain.swf",WebSocket.__addTask(function(){Pusher.ready()}),WebSocket.__initialize()):(Pusher.Transport=null,Pusher.TransportType="none",Pusher.ready())}}(),e=function(a){var b=function(){document.body?a():setTimeout(b,0)};b()},g=function(){e(b)};a.length>0?_require(a,g):g()})(); -;minispade.register('app', "(function() {(function() {\nminispade.require('auth');\nminispade.require('controllers');\nminispade.require('helpers');\nminispade.require('models');\nminispade.require('pusher');\nminispade.require('routes');\nminispade.require('slider');\nminispade.require('store');\nminispade.require('tailing');\nminispade.require('templates');\nminispade.require('views');\nminispade.require('config/locales');\nminispade.require('data/sponsors');\n\n Travis.reopen({\n App: Em.Application.extend({\n autoinit: false,\n currentUserBinding: 'auth.user',\n authStateBinding: 'auth.state',\n init: function() {\n this._super.apply(this, arguments);\n this.store = Travis.Store.create();\n this.store.loadMany(Travis.Sponsor, Travis.SPONSORS);\n this.slider = new Travis.Slider();\n this.pusher = new Travis.Pusher(Travis.config.pusher_key);\n this.tailing = new Travis.Tailing();\n return this.set('auth', Travis.Auth.create({\n app: this,\n endpoint: Travis.config.api_endpoint\n }));\n },\n storeAfterSignInPath: function(path) {\n return this.get('auth').storeAfterSignInPath(path);\n },\n autoSignIn: function(path) {\n return this.get('auth').autoSignIn(path);\n },\n signIn: function() {\n return this.get('auth').signIn();\n },\n signOut: function() {\n this.get('auth').signOut();\n return this.get('router').send('afterSignOut');\n },\n receive: function() {\n return this.store.receive.apply(this.store, arguments);\n },\n toggleSidebar: function() {\n var element;\n $('body').toggleClass('maximized');\n element = $('');\n $('#top .profile').append(element);\n Em.run.later((function() {\n return element.remove();\n }), 10);\n element = $('');\n $('#repo').append(element);\n return Em.run.later((function() {\n return element.remove();\n }), 10);\n }\n })\n });\n\n}).call(this);\n\n})();\n//@ sourceURL=app");minispade.register('auth', "(function() {(function() {\n\n this.Travis.Auth = Ember.Object.extend({\n iframe: $('