moar specs. test setup still fucked

This commit is contained in:
Sven Fuchs 2012-07-08 20:48:09 +02:00
parent fb618f05a7
commit ba0e3827de
30 changed files with 831 additions and 446 deletions

View File

@ -13,22 +13,13 @@ Travis.reopen
@connectOutlet(outletName: 'top', controller: @topController, viewClass: Travis.TopView)
@topController.set('tab', @get('name'))
BuildsController: Em.ArrayController.extend
repositoryBinding: 'parent.repository'
contentBinding: 'parent.builds'
QueuesController: Em.ArrayController.extend()
UserController: Em.Controller.extend()
HooksController: Em.ArrayController.extend()
# TopController: Em.Controller.extend
# userBinding: 'Travis.app.currentUser'
require 'controllers/builds'
require 'controllers/home'
require 'controllers/profile'
require 'controllers/repository'
require 'controllers/repositories'
require 'controllers/repository'
require 'controllers/sidebar'
require 'controllers/sponsors'
require 'controllers/stats'
require 'controllers/workers'

View File

@ -0,0 +1,7 @@
Travis.BuildsController = Em.ArrayController.extend
# sortAscending: false
repositoryBinding: 'parent.repository'
contentBinding: 'parent.builds'

View File

@ -1,4 +1,5 @@
Travis.ProfileController = Travis.Controller.extend
Travis.reopen
ProfileController: Travis.Controller.extend
name: 'profile'
init: ->
@ -18,3 +19,6 @@ Travis.ProfileController = Travis.Controller.extend
connectHooks: (hooks) ->
@userController.connectOutlet(outletName: 'hooks', name: 'hooks', context: hooks) if hooks
UserController: Em.Controller.extend()
HooksController: Em.ArrayController.extend()

View File

@ -8,7 +8,6 @@ Travis.RepositoryController = Travis.Controller.extend
activate: (action, params) ->
@_unbind()
@setParams(params)
# console.log "view#{$.camelize(action)}"
this["view#{$.camelize(action)}"]()
viewIndex: ->
@ -17,14 +16,14 @@ Travis.RepositoryController = Travis.Controller.extend
@connectTab('current')
viewCurrent: ->
@connectTab('current')
@_bind('repository', 'repositoriesByParams.firstObject')
@_bind('build', 'repository.lastBuild')
@connectTab('current')
viewBuilds: ->
@connectTab('builds')
@_bind('repository', 'repositoriesByParams.firstObject')
@_bind('builds', 'repository.builds')
@connectTab('builds')
viewBuild: ->
@_bind('repository', 'repositoriesByParams.firstObject')

View File

@ -1,4 +1,5 @@
Travis.SidebarController = Em.ArrayController.extend
Travis.reopen
SidebarController: Em.ArrayController.extend
init: ->
@tickables = []
Travis.Ticker.create(target: this, interval: Travis.INTERVALS.sponsors)
@ -32,4 +33,43 @@ Travis.SidebarController = Em.ArrayController.extend
tick: ->
tickable.tick() for tickable in @tickables
QueuesController: Em.ArrayController.extend()
WorkersController: Em.ArrayController.extend
groups: (->
groups = {}
for worker in @get('content').toArray()
host = worker.get('host')
groups[host] = Em.ArrayProxy.create(content: []) if !(host in groups)
groups[host].pushObject(worker)
$.values(groups)
).property('content.length')
SponsorsController: Em.ArrayController.extend
page: 0
arrangedContent: (->
@get('shuffled').slice(@start(), @end())
).property('shuffled.length', 'page')
shuffled: (->
if content = @get('content') then $.shuffle(content) else []
).property('content.length')
tick: ->
@set('page', if @isLast() then 0 else @get('page') + 1)
pages: (->
length = @getPath('content.length')
if length then parseInt(length / @get('perPage') + 1) else 1
).property('length')
isLast: ->
@get('page') == @get('pages') - 1
start: ->
@get('page') * @get('perPage')
end: ->
@start() + @get('perPage')

View File

@ -1,27 +0,0 @@
Travis.SponsorsController = Em.ArrayController.extend
page: 0
arrangedContent: (->
@get('shuffled').slice(@start(), @end())
).property('shuffled.length', 'page')
shuffled: (->
if content = @get('content') then $.shuffle(content) else []
).property('content.length')
tick: ->
@set('page', if @isLast() then 0 else @get('page') + 1)
pages: (->
length = @getPath('content.length')
if length then parseInt(length / @get('perPage') + 1) else 1
).property('length')
isLast: ->
@get('page') == @get('pages') - 1
start: ->
@get('page') * @get('perPage')
end: ->
@start() + @get('perPage')

View File

@ -1,10 +0,0 @@
Travis.WorkersController = Em.ArrayController.extend
groups: (->
groups = {}
for worker in @get('content').toArray()
host = worker.get('host')
groups[host] = Em.ArrayProxy.create(content: []) if !(host in groups)
groups[host].pushObject(worker)
$.values(groups)
).property('content.length')

View File

@ -1,36 +1,34 @@
require 'travis/model'
@Travis.Build = Travis.Model.extend
eventType: DS.attr('string')
repositoryId: DS.attr('number')
commitId: DS.attr('number')
state: DS.attr('string')
number: DS.attr('number')
branch: DS.attr('string')
message: DS.attr('string')
result: DS.attr('number')
duration: DS.attr('number')
started_at: DS.attr('string')
finished_at: DS.attr('string')
committed_at: DS.attr('string')
committer_name: DS.attr('string')
committer_email: DS.attr('string')
author_name: DS.attr('string')
author_email: DS.attr('string')
compare_url: DS.attr('string')
startedAt: DS.attr('string')
finishedAt: DS.attr('string')
# committedAt: DS.attr('string')
# committerName: DS.attr('string')
# committerEmail: DS.attr('string')
# authorName: DS.attr('string')
# authorEmail: DS.attr('string')
# compareUrl: DS.attr('string')
repository: DS.belongsTo('Travis.Repository', key: 'repository_id')
commit: DS.belongsTo('Travis.Commit')
# jobs: DS.hasMany('Travis.Job')
jobs: DS.hasMany('Travis.Job', key: 'job_ids')
config: (->
@getPath 'data.config'
).property('data.config')
# TODO why does the hasMany association not work?
jobs: (->
Travis.Job.findMany(@getPath('data.job_ids') || [])
).property('data.job_ids.length')
isMatrix: (->
@getPath('data.job_ids.length') > 1
).property('data.job_ids.length')

View File

@ -2,22 +2,23 @@ require 'travis/model'
@Travis.Job = Travis.Model.extend
repositoryId: DS.attr('number')
commitId: DS.attr('number')
buildId: DS.attr('number')
commitId: DS.attr('number')
logId: DS.attr('number')
queue: DS.attr('string')
state: DS.attr('string')
number: DS.attr('string')
result: DS.attr('number')
duration: DS.attr('number')
started_at: DS.attr('string')
finished_at: DS.attr('string')
allow_failure: DS.attr('boolean')
startedAt: DS.attr('string')
finishedAt: DS.attr('string')
allowFailure: DS.attr('boolean')
repository: DS.belongsTo('Travis.Repository')
commit: DS.belongsTo('Travis.Commit')
build: DS.belongsTo('Travis.Build')
log: DS.belongsTo('Travis.Artifact')
repository: DS.belongsTo('Travis.Repository', key: 'repository_id')
build: DS.belongsTo('Travis.Build', key: 'build_id')
commit: DS.belongsTo('Travis.Commit', key: 'commit_id')
log: DS.belongsTo('Travis.Artifact', key: 'log_id')
config: (->
@getPath 'data.config'

View File

@ -14,11 +14,15 @@ require 'travis/model'
lastBuild: DS.belongsTo('Travis.Build')
builds: (->
Travis.Build.byRepositoryId @get('id'), event_type: 'push'
id = @get('id')
Travis.Build.byRepositoryId id, event_type: 'push'
Travis.Build.filter (data) -> parseInt(data.get('repository_id')) == id && data.get('event_type') == 'push'
).property()
pullRequests: (->
Travis.Build.byRepositoryId @get('id'), event_type: 'pull_request'
id = @get('id')
Travis.Build.byRepositoryId id, event_type: 'pull_request'
Travis.Build.filter (data) -> parseInt(data.get('repository_id')) == id && data.get('event_type') == 'pull_request'
).property()
branches: (->

View File

@ -19,9 +19,17 @@ Travis.Store = DS.Store.extend
root = type.singularName()
@adapter.sideload(store, type, json, root)
type.load(json[root])
@_updateAssociations(type, json[root])
_loadMany: (store, type, json) ->
root = type.pluralName()
@adapter.sideload(store, type, json, root)
@loadMany(type, json[root])
# _loadMany: (store, type, json) ->
# root = type.pluralName()
# @adapter.sideload(store, type, json, root)
# @loadMany(type, json[root])
_updateAssociations: (type, data) ->
Em.get(type, 'associationsByName').forEach (key, meta) =>
if meta.kind == 'belongsTo' && id = data["#{key}_id"]
parent = type.find(data.id).getPath("#{key}.data")
ids = parent.get("#{root}_ids")
parent.set("#{root}_ids", ids.concat(data.id)) if ids && !(data.id in ids)

View File

@ -1,5 +1,4 @@
{{#if builds.isLoaded}}
<table id="builds" class="list">
<table id="builds" class="list">
<thead>
<tr>
<th>{{t builds.name}}</th>
@ -23,15 +22,10 @@
{{/view}}
{{/each}}
</tbody>
</table>
</table>
<p>
<p>
<button {{action showMore on="click" target="builds" isVisibleBinding="hasMore"}}>
{{t builds.show_more}}
</button>
</p>
{{else}}
<div id="builds" class="loading">
<span>Loading</span>
</div>
{{/if}}
</p>

View File

@ -6,7 +6,7 @@
<dt>{{t builds.name}}</dt>
<dd class="number"><a {{bindAttr href="urlBuild"}}>{{build.number}}</a></dd>
<dt class="finished_at_label">{{t builds.finished_at}}</dt>
<dd class="finished_at timeago" {{bindAttr title="finished_at"}}>{{formatTime build.finished_at}}</dd>
<dd class="finished_at timeago" {{bindAttr title="finished_at"}}>{{formatTime build.finishedAt}}</dd>
<dt>{{t builds.duration}}</dt>
<dd class="duration" {{bindAttr title="started_at"}}>{{formatDuration build.duration}}</dd>
</div>

View File

@ -1,6 +1,5 @@
{{#with view}}
{{#if jobs.length}}
{{#if required}}
{{#if view.jobs.length}}
{{#if view.required}}
<table id="jobs" class="list">
<caption>
{{t jobs.build_matrix}}
@ -14,20 +13,20 @@
{{/if}}
<thead>
<tr>
{{#each build.configKeys}}
<th>{{this}}</th>
{{#each key in view.build.configKeys}}
<th>{{key}}</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#each job in jobs}}
{{#each job in view.jobs}}
{{#view Travis.JobsItemView contextBinding="job"}}
<tr {{bindAttr class="view.color"}}>
<td class="number"><a {{bindAttr href="view.urlJob"}}>{{number}}</a></td>
<td class="duration" {{bindAttr title="started_at"}}>{{formatDuration duration}}</td>
<td class="finished_at timeago" {{bindAttr title="finished_at"}}>{{formatTime finished_at}}</td>
{{#each configValues}}
<td>{{this}}</td>
<td class="finished_at timeago" {{bindAttr title="finishedAt"}}>{{formatTime finishedAt}}</td>
{{#each value in configValues}}
<td>{{value}}</td>
{{/each}}
</tr>
{{/view}}
@ -54,5 +53,4 @@
</div>
</div>
{{/unless}}
{{/if}}
{{/with}}
{{/if}}

View File

@ -6,17 +6,17 @@
<dt>Job</dt>
<dd class="number"><a {{bindAttr href="view.urlJob"}}>{{job.number}}</a></dd>
<dt class="finished_at_label">{{t jobs.finished_at}}</dt>
<dd class="finished_at timeago" {{bindAttr title="finished_at"}}>{{formatTime job.finished_at}}</dd>
<dd class="finished_at timeago" {{bindAttr title="finished_at"}}>{{formatTime job.finishedAt}}</dd>
<dt>{{t jobs.duration}}</dt>
<dd class="duration" {{bindAttr title="started_at"}}>{{formatDuration job.duration}}</dd>
</div>
<div class="right">
<dt>{{t jobs.commit}}</dt>
<dd class="commit-hash"><a {{bindAttr href="urlGithubCommit"}}>{{formatCommit commit}}</a></dd>
<dd class="commit"><a {{bindAttr href="urlGithubCommit"}}>{{formatCommit commit}}</a></dd>
{{#if commit.compareUrl}}
<dt>{{t jobs.compare}}</dt>
<dd class="compare_view"><a {{bindAttr href="commit.compareUrl"}}>{{pathFrom commit.compareUrl}}</a></dd>
<dd class="compare"><a {{bindAttr href="commit.compareUrl"}}>{{pathFrom commit.compareUrl}}</a></dd>
{{/if}}
{{#if commit.authorName}}
<dt>{{t jobs.author}}</dt>
@ -29,7 +29,7 @@
</div>
<dt>{{t jobs.message}}</dt>
<dd class="commit-message">{{formatMessage commit.message}}</dd>
<dd class="message">{{formatMessage commit.message}}</dd>
<dt>{{t jobs.config}}</dt>
<dd class="config">{{formatConfig job.config}}</dd>
</dl>

View File

@ -49,10 +49,10 @@
requiredJobs: (->
jobs = @getPath('build.jobs')
jobs.filter((job) -> job.get('allow_failure') != true) if jobs
jobs.filter((job) -> job.get('allowFailure') != true) if jobs
).property('build.jobs')
allowedFailureJobs: (->
jobs = @getPath('build.jobs')
jobs.filter((job) -> job.get('allow_failure')) if jobs
jobs.filter((job) -> job.get('allowFailure')) if jobs
).property('build.jobs')

View File

@ -9,10 +9,10 @@ repositories = [
]
builds = [
{ id: 1, repository_id: '1', commit_id: 1, job_ids: [1, 2], number: 1, event_type: 'push', config: { rvm: ['rbx', '1.9.3'] }, duration: 30, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:30Z', result: 0 },
{ id: 2, repository_id: '1', commit_id: 2, job_ids: [3], number: 2, event_type: 'push', config: { rvm: ['rbx'] } },
{ id: 3, repository_id: '2', commit_id: 3, job_ids: [4], number: 3, event_type: 'push', config: { rvm: ['rbx'] }, duration: 30, started_at: '2012-07-02T00:01:00Z', finished_at: '2012-07-01T00:01:30Z', result: 1 },
{ id: 4, repository_id: '3', commit_id: 4, job_ids: [5], number: 4, event_type: 'push', config: { rvm: ['rbx'] }, started_at: '2012-07-02T00:02:00Z' },
{ id: 1, repository_id: '1', commit_id: 1, job_ids: [1, 2, 3], number: 1, event_type: 'push', config: { rvm: ['rbx', '1.9.3', 'jruby'] }, duration: 30, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:30Z', result: 0 },
{ id: 2, repository_id: '1', commit_id: 2, job_ids: [4], number: 2, event_type: 'push', config: { rvm: ['rbx'] } },
{ id: 3, repository_id: '2', commit_id: 3, job_ids: [5], number: 3, event_type: 'push', config: { rvm: ['rbx'] }, duration: 30, started_at: '2012-07-02T00:01:00Z', finished_at: '2012-07-01T00:01:30Z', result: 1 },
{ id: 4, repository_id: '3', commit_id: 4, job_ids: [6], number: 4, event_type: 'push', config: { rvm: ['rbx'] }, started_at: '2012-07-02T00:02:00Z' },
]
commits = [
@ -24,12 +24,13 @@ commits = [
jobs = [
{ id: 1, repository_id: 1, build_id: 1, commit_id: 1, log_id: 1, number: '1.1', config: { rvm: 'rbx' }, duration: 30, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:30Z', result: 0 }
{ id: 2, repository_id: 1, build_id: 1, commit_id: 1, log_id: 2, number: '1.2', config: { rvm: '1.9.3' }, allow_failure: true }
{ id: 3, repository_id: 1, build_id: 2, commit_id: 2, log_id: 3, number: '2.1', config: { rvm: 'rbx' } }
{ id: 4, repository_id: 2, build_id: 3, commit_id: 3, log_id: 4, number: '3.1', config: { rvm: 'rbx' }, duration: 30, started_at: '2012-07-02T00:01:00Z', finished_at: '2012-07-02T00:01:30Z', result: 1 }
{ id: 5, repository_id: 3, build_id: 4, commit_id: 4, log_id: 5, number: '4.1', config: { rvm: 'rbx' }, started_at: '2012-07-02T00:02:00Z' }
{ id: 6, repository_id: 1, build_id: 5, commit_id: 5, log_id: 5, number: '5.1', config: { rvm: 'rbx' }, state: 'created', queue: 'builds.common' }
{ id: 7, repository_id: 1, build_id: 5, commit_id: 5, log_id: 5, number: '5.2', config: { rvm: 'rbx' }, state: 'created', queue: 'builds.common' }
{ id: 2, repository_id: 1, build_id: 1, commit_id: 1, log_id: 2, number: '1.2', config: { rvm: '1.9.3' }, duration: 40, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:40Z', result: 1 }
{ id: 3, repository_id: 1, build_id: 1, commit_id: 1, log_id: 3, number: '1.3', config: { rvm: 'jruby' }, allow_failure: true }
{ id: 4, repository_id: 1, build_id: 2, commit_id: 2, log_id: 4, number: '2.1', config: { rvm: 'rbx' } }
{ id: 5, repository_id: 2, build_id: 3, commit_id: 3, log_id: 5, number: '3.1', config: { rvm: 'rbx' }, duration: 30, started_at: '2012-07-02T00:01:00Z', finished_at: '2012-07-02T00:01:30Z', result: 1 }
{ id: 6, repository_id: 3, build_id: 4, commit_id: 4, log_id: 6, number: '4.1', config: { rvm: 'rbx' }, started_at: '2012-07-02T00:02:00Z' }
{ id: 7, repository_id: 1, build_id: 5, commit_id: 5, log_id: 7, number: '5.1', config: { rvm: 'rbx' }, state: 'created', queue: 'builds.common' }
{ id: 8, repository_id: 1, build_id: 5, commit_id: 5, log_id: 8, number: '5.2', config: { rvm: 'rbx' }, state: 'created', queue: 'builds.common' }
]
artifacts = [
@ -37,7 +38,10 @@ artifacts = [
{ id: 2, body: 'log 2' }
{ id: 3, body: 'log 3' }
{ id: 4, body: 'log 4' }
{ id: 5, body: 'log 4' }
{ id: 5, body: 'log 5' }
{ id: 6, body: 'log 6' }
{ id: 7, body: 'log 7' }
{ id: 8, body: 'log 8' }
]
branches = [

View File

@ -12,6 +12,9 @@
this
@Travis.Model.reopenClass
filter: (callback) ->
Travis.app.store.filter(this, callback)
load: (attrs) ->
Travis.app.store.load(this, attrs)

View File

@ -0,0 +1,46 @@
describe 'on the "build" state', ->
beforeEach ->
app '!/travis-ci/travis-core/builds/1'
waitFor buildRendered
it 'displays the expected stuff', ->
displaysReposList [
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '#!/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
{ slug: 'travis-ci/travis-assets', build: { number: 3, url: '#!/travis-ci/travis-assets/builds/3', duration: '30 sec', finishedAt: 'a day ago' } }
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '#!/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
]
displaysRepository
href: 'http://github.com/travis-ci/travis-core'
displaysSummary
type: 'build'
id: 1
repo: 'travis-ci/travis-core'
commit: '1234567'
branch: 'master'
compare: '0123456..1234567'
finishedAt: '3 minutes ago'
duration: '30 sec'
message: 'commit message 1'
displaysTabs
current: { href: '#!/travis-ci/travis-core' }
builds: { href: '#!/travis-ci/travis-core/builds' }
build: { href: '#!/travis-ci/travis-core/builds/1', active: true }
job: { hidden: true }
displaysJobMatrix
element: '#jobs'
headers: ['Job', 'Duration', 'Finished', 'Rvm']
jobs: [
{ id: 1, number: '1.1', repo: 'travis-ci/travis-core', finishedAt: '3 minutes ago', duration: '30 sec', rvm: 'rbx' }
{ id: 2, number: '1.2', repo: 'travis-ci/travis-core', finishedAt: '2 minutes ago', duration: '40 sec', rvm: '1.9.3' }
]
displaysJobMatrix
element: '#allowed_failure_jobs'
headers: ['Job', 'Duration', 'Finished', 'Rvm']
jobs: [
{ id: 3, number: '1.3', repo: 'travis-ci/travis-core', finishedAt: '-', duration: '-', rvm: 'jruby' }
]

View File

@ -0,0 +1,27 @@
# describe 'on the "builds" state', ->
# beforeEach ->
# app '!/travis-ci/travis-core/builds'
# waitFor buildsRendered
#
# it 'displays the expected stuff', ->
# displaysReposList [
# { slug: 'travis-ci/travis-core', build: { number: 1, url: '#!/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
# { slug: 'travis-ci/travis-assets', build: { number: 3, url: '#!/travis-ci/travis-assets/builds/3', duration: '30 sec', finishedAt: 'a day ago' } }
# { slug: 'travis-ci/travis-hub', build: { number: 4, url: '#!/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
# ]
#
# displaysRepository
# href: 'http://github.com/travis-ci/travis-core'
#
# displaysTabs
# current: { href: '#!/travis-ci/travis-core' }
# builds: { href: '#!/travis-ci/travis-core/builds', active: true }
# build: { hidden: true }
# job: { hidden: true }
#
# displaysBuildsList [
# { id: 1, slug: 'travis-ci/travis-core', number: '1', sha: '1234567', branch: 'master', message: 'commit message 1', duration: '30 sec', finishedAt: '3 minutes ago' }
# { id: 2, slug: 'travis-ci/travis-core', number: '2', sha: '2345678', branch: 'feature', message: 'commit message 2', duration: '-', finishedAt: '-' }
# ]
#
#

View File

@ -1,17 +1,20 @@
describe 'on the "current" state', ->
beforeEach ->
app '!/travis-ci/travis-core'
waitFor repositoriesRendered
waitFor buildRendered
it 'displays the expected stuff', ->
displaysRepoList [
displaysReposList [
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '#!/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
{ slug: 'travis-ci/travis-assets', build: { number: 3, url: '#!/travis-ci/travis-assets/builds/3', duration: '30 sec', finishedAt: 'a day ago' } }
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '#!/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
]
displaysBuildSummary
displaysRepository
href: 'http://github.com/travis-ci/travis-core'
displaysSummary
type: 'build'
id: 1
repo: 'travis-ci/travis-core'
commit: '1234567'
@ -22,19 +25,22 @@ describe 'on the "current" state', ->
message: 'commit message 1'
displaysTabs
current: '#!/travis-ci/travis-core'
builds: '#!/travis-ci/travis-core/builds'
current: { href: '#!/travis-ci/travis-core', active: true }
builds: { href: '#!/travis-ci/travis-core/builds' }
build: { hidden: true }
job: { hidden: true }
displaysJobMatrix
element: '#jobs'
headers: ['Job', 'Duration', 'Finished', 'Rvm']
jobs: [
{ id: 1, number: '1.1', repo: 'travis-ci/travis-core', finishedAt: '3 minutes ago', duration: '30 sec', rvm: 'rbx' }
{ id: 2, number: '1.2', repo: 'travis-ci/travis-core', finishedAt: '2 minutes ago', duration: '40 sec', rvm: '1.9.3' }
]
displaysJobMatrix
element: '#allowed_failure_jobs'
headers: ['Job', 'Duration', 'Finished', 'Rvm']
jobs: [
{ id: 2, number: '1.2', repo: 'travis-ci/travis-core', finishedAt: '-', duration: '-', rvm: '1.9.3' }
{ id: 3, number: '1.3', repo: 'travis-ci/travis-core', finishedAt: '-', duration: '-', rvm: 'jruby' }
]

View File

@ -1,9 +1,9 @@
describe 'events', ->
beforeEach ->
app
waitFor buildRendered
it 'foo', ->
# describe 'events', ->
# beforeEach ->
# app
# waitFor buildRendered
#
# it 'foo', ->
# Travis.app.receive 'job:created',
# job:
# id: 10
@ -24,32 +24,32 @@ describe 'events', ->
# compare_url: 'http://github.com/compare/0123456..1234567'
Travis.app.receive 'build:started',
repository:
id: 10
owner: 'travis-ci'
name: 'travis-support'
slug: 'travis-ci/travis-support'
build_ids: [10]
last_build_id: 10
last_build_number: 10
last_build_started_at: '2012-07-02T00:02:00Z'
description: 'Description of travis-hub'
build:
id: 10
repository_id: 1
commit_id: 10
job_ids: [10]
number: 10
event_type: 'push'
config: { rvm: ['rbx'] }
commit:
id: 10
sha: '1234567'
branch: 'master'
message: 'commit message 1'
author_name: 'author name'
author_email: 'author@email.com'
committer_name: 'committer name'
committer_email: 'committer@email.com'
compare_url: 'http://github.com/compare/0123456..1234567'
# Travis.app.receive 'build:started',
# repository:
# id: 10
# owner: 'travis-ci'
# name: 'travis-support'
# slug: 'travis-ci/travis-support'
# build_ids: [10]
# last_build_id: 10
# last_build_number: 10
# last_build_started_at: '2012-07-02T00:02:00Z'
# description: 'Description of travis-hub'
# build:
# id: 10
# repository_id: 1
# commit_id: 10
# job_ids: [10]
# number: 10
# event_type: 'push'
# config: { rvm: ['rbx'] }
# commit:
# id: 10
# sha: '1234567'
# branch: 'master'
# message: 'commit message 1'
# author_name: 'author name'
# author_email: 'author@email.com'
# committer_name: 'committer name'
# committer_email: 'committer@email.com'
# compare_url: 'http://github.com/compare/0123456..1234567'

View File

@ -4,7 +4,7 @@ describe 'on the "index" state', ->
waitFor buildRendered
it 'displays the expected stuff', ->
displaysRepoList [
displaysReposList [
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '#!/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
{ slug: 'travis-ci/travis-assets', build: { number: 3, url: '#!/travis-ci/travis-assets/builds/3', duration: '30 sec', finishedAt: 'a day ago' } }
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '#!/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
@ -13,7 +13,8 @@ describe 'on the "index" state', ->
displaysRepository
href: 'http://github.com/travis-ci/travis-core'
displaysBuildSummary
displaysSummary
type: 'build'
id: 1
repo: 'travis-ci/travis-core'
commit: '1234567'
@ -24,21 +25,22 @@ describe 'on the "index" state', ->
message: 'commit message 1'
displaysTabs
current: '#!/travis-ci/travis-core'
builds: '#!/travis-ci/travis-core/builds'
current: { href: '#!/travis-ci/travis-core', active: true }
builds: { href: '#!/travis-ci/travis-core/builds' }
build: { hidden: true }
job: { hidden: true }
displaysJobMatrix
element: '#jobs'
headers: ['Job', 'Duration', 'Finished', 'Rvm']
jobs: [
{ id: 1, number: '1.1', repo: 'travis-ci/travis-core', finishedAt: '3 minutes ago', duration: '30 sec', rvm: 'rbx' }
{ id: 2, number: '1.2', repo: 'travis-ci/travis-core', finishedAt: '2 minutes ago', duration: '40 sec', rvm: '1.9.3' }
]
displaysJobMatrix
element: '#allowed_failure_jobs'
headers: ['Job', 'Duration', 'Finished', 'Rvm']
jobs: [
{ id: 2, number: '1.2', repo: 'travis-ci/travis-core', finishedAt: '-', duration: '-', rvm: '1.9.3' }
{ id: 3, number: '1.3', repo: 'travis-ci/travis-core', finishedAt: '-', duration: '-', rvm: 'jruby' }
]

View File

@ -0,0 +1,36 @@
describe 'on the "job" state', ->
beforeEach ->
app '!/travis-ci/travis-core/jobs/1'
waitFor jobRendered
waitFor hasText('#tab_build', 'Build #1')
it 'displays the expected stuff', ->
displaysReposList [
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '#!/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
{ slug: 'travis-ci/travis-assets', build: { number: 3, url: '#!/travis-ci/travis-assets/builds/3', duration: '30 sec', finishedAt: 'a day ago' } }
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '#!/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
]
displaysRepository
href: 'http://github.com/travis-ci/travis-core'
displaysSummary
id: 1
type: 'job'
repo: 'travis-ci/travis-core'
commit: '1234567'
branch: 'master'
compare: '0123456..1234567'
finishedAt: '3 minutes ago'
duration: '30 sec'
message: 'commit message 1'
displaysTabs
current: { href: '#!/travis-ci/travis-core' }
builds: { href: '#!/travis-ci/travis-core/builds' }
build: { href: '#!/travis-ci/travis-core/builds/1' }
job: { href: '#!/travis-ci/travis-core/jobs/1', active: true }
displaysLog [
'log 1'
]

View File

@ -1,7 +1,9 @@
minispade.require 'app'
@reset = ->
Em.run ->
Travis.app.destroy() if Travis.app
waits(500) # TODO not sure what we need to wait for here
$('#content').remove()
$('body').append('<div id="content"></div>')

View File

@ -1,10 +1,12 @@
@repositoriesRendered = ->
$('#repositories li a.current').text() != ''
@notEmpty = (selector) ->
-> $(selector).text().trim() != ''
@buildRendered = ->
$('#summary .number').text() != ''
@matrixRendered = ->
$('#jobs').text() != ''
@hasText = (selector, text) ->
-> $(selector).text().trim() == text
@reposRendered = notEmpty('#repositories li a.current')
@buildRendered = notEmpty('#summary .number')
@buildsRendered = notEmpty('#builds .number')
@matrixRendered = notEmpty('#jobs')
@jobRendered = notEmpty('#summary .number')

View File

@ -1,4 +1,4 @@
@displaysRepoList = (repos) ->
@displaysReposList = (repos) ->
elements = $('#repositories li').toArray()
ix = 0
for repo in repos
@ -13,12 +13,18 @@
expect($('#repository h3 a').attr('href')).toEqual (repo.href)
@displaysTabs = (tabs) ->
for tab, url in tabs
expect($("#tab_#{tab} a").attr('href')).toEqual url
for name, tab of tabs
expect($("#tab_#{name} a").attr('href')).toEqual tab.href unless tab.hidden
expect($("#tab_#{name}").hasClass('active')).toEqual !!tab.active
expect($("#tab_#{name}").hasClass('display')).toEqual !tab.hidden if name in ['build', 'job']
@displaysSummary = (data) ->
element = $('#summary .left:first-child dt:first-child')
expect(element.text()).toEqual $.camelize(data.type)
@displaysBuildSummary = (data) ->
element = $('#summary .number a')
expect(element.attr('href')).toEqual "#!/#{data.repo}/builds/#{data.id}"
expect(element.attr('href')).toEqual "#!/#{data.repo}/#{data.type}s/#{data.id}"
element = $('#summary .finished_at')
expect(element.text()).toEqual data.finishedAt
@ -63,5 +69,22 @@
element = $("#{data.element} tr:nth-child(#{ix}) td:nth-child(6)")
expect(element.text()).toEqual job.rvm
@displaysBuildsList = (builds) ->
rows = $('#builds tbody tr').toArray()
ix = 0
for build in builds
row = rows[ix]
expect($('.number a', row).attr('href')).toEqual "#!/#{build.slug}/builds/#{build.id}"
expect($('.number a', row).text()).toEqual build.number
expect($('.message', row).text()).toEqual build.message
expect($('.duration', row).text()).toEqual build.duration
expect($('.finished_at', row).text()).toEqual build.finishedAt
ix += 1
@displaysLog = (lines) ->
ix = 0
log = $.map(lines, (line) -> ix += 1; "#{ix}#{line}").join("\n")
expect($('#log').text().trim()).toEqual log

File diff suppressed because one or more lines are too long

View File

@ -1,141 +1,12 @@
(function() {
describe('on the "current" state', function() {
describe('on the "build" state', function() {
beforeEach(function() {
app('!/travis-ci/travis-core');
waitFor(repositoriesRendered);
app('!/travis-ci/travis-core/builds/1');
return waitFor(buildRendered);
});
return it('displays the expected stuff', function() {
displaysRepoList([
{
slug: 'travis-ci/travis-core',
build: {
number: 1,
url: '#!/travis-ci/travis-core/builds/1',
duration: '30 sec',
finishedAt: '3 minutes ago'
}
}, {
slug: 'travis-ci/travis-assets',
build: {
number: 3,
url: '#!/travis-ci/travis-assets/builds/3',
duration: '30 sec',
finishedAt: 'a day ago'
}
}, {
slug: 'travis-ci/travis-hub',
build: {
number: 4,
url: '#!/travis-ci/travis-hub/builds/4',
duration: '1 min',
finishedAt: '-'
}
}
]);
displaysBuildSummary({
id: 1,
repo: 'travis-ci/travis-core',
commit: '1234567',
branch: 'master',
compare: '0123456..1234567',
finishedAt: '3 minutes ago',
duration: '30 sec',
message: 'commit message 1'
});
displaysTabs({
current: '#!/travis-ci/travis-core',
builds: '#!/travis-ci/travis-core/builds'
});
displaysJobMatrix({
element: '#jobs',
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
jobs: [
{
id: 1,
number: '1.1',
repo: 'travis-ci/travis-core',
finishedAt: '3 minutes ago',
duration: '30 sec',
rvm: 'rbx'
}
]
});
return displaysJobMatrix({
element: '#allowed_failure_jobs',
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
jobs: [
{
id: 2,
number: '1.2',
repo: 'travis-ci/travis-core',
finishedAt: '-',
duration: '-',
rvm: '1.9.3'
}
]
});
});
});
}).call(this);
(function() {
describe('events', function() {
beforeEach(function() {
app;
return waitFor(buildRendered);
});
return it('foo', function() {
return Travis.app.receive('build:started', {
repository: {
id: 10,
owner: 'travis-ci',
name: 'travis-support',
slug: 'travis-ci/travis-support',
build_ids: [10],
last_build_id: 10,
last_build_number: 10,
last_build_started_at: '2012-07-02T00:02:00Z',
description: 'Description of travis-hub'
},
build: {
id: 10,
repository_id: 1,
commit_id: 10,
job_ids: [10],
number: 10,
event_type: 'push',
config: {
rvm: ['rbx']
}
},
commit: {
id: 10,
sha: '1234567',
branch: 'master',
message: 'commit message 1',
author_name: 'author name',
author_email: 'author@email.com',
committer_name: 'committer name',
committer_email: 'committer@email.com',
compare_url: 'http://github.com/compare/0123456..1234567'
}
});
});
});
}).call(this);
(function() {
describe('on the "index" state', function() {
beforeEach(function() {
app('');
return waitFor(buildRendered);
});
return it('displays the expected stuff', function() {
displaysRepoList([
displaysReposList([
{
slug: 'travis-ci/travis-core',
build: {
@ -165,7 +36,8 @@
displaysRepository({
href: 'http://github.com/travis-ci/travis-core'
});
displaysBuildSummary({
displaysSummary({
type: 'build',
id: 1,
repo: 'travis-ci/travis-core',
commit: '1234567',
@ -176,8 +48,19 @@
message: 'commit message 1'
});
displaysTabs({
current: '#!/travis-ci/travis-core',
builds: '#!/travis-ci/travis-core/builds'
current: {
href: '#!/travis-ci/travis-core'
},
builds: {
href: '#!/travis-ci/travis-core/builds'
},
build: {
href: '#!/travis-ci/travis-core/builds/1',
active: true
},
job: {
hidden: true
}
});
displaysJobMatrix({
element: '#jobs',
@ -190,6 +73,13 @@
finishedAt: '3 minutes ago',
duration: '30 sec',
rvm: 'rbx'
}, {
id: 2,
number: '1.2',
repo: 'travis-ci/travis-core',
finishedAt: '2 minutes ago',
duration: '40 sec',
rvm: '1.9.3'
}
]
});
@ -198,15 +88,301 @@
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
jobs: [
{
id: 2,
number: '1.2',
id: 3,
number: '1.3',
repo: 'travis-ci/travis-core',
finishedAt: '-',
duration: '-',
rvm: 'jruby'
}
]
});
});
});
}).call(this);
(function() {
}).call(this);
(function() {
describe('on the "current" state', function() {
beforeEach(function() {
app('!/travis-ci/travis-core');
return waitFor(buildRendered);
});
return it('displays the expected stuff', function() {
displaysReposList([
{
slug: 'travis-ci/travis-core',
build: {
number: 1,
url: '#!/travis-ci/travis-core/builds/1',
duration: '30 sec',
finishedAt: '3 minutes ago'
}
}, {
slug: 'travis-ci/travis-assets',
build: {
number: 3,
url: '#!/travis-ci/travis-assets/builds/3',
duration: '30 sec',
finishedAt: 'a day ago'
}
}, {
slug: 'travis-ci/travis-hub',
build: {
number: 4,
url: '#!/travis-ci/travis-hub/builds/4',
duration: '1 min',
finishedAt: '-'
}
}
]);
displaysRepository({
href: 'http://github.com/travis-ci/travis-core'
});
displaysSummary({
type: 'build',
id: 1,
repo: 'travis-ci/travis-core',
commit: '1234567',
branch: 'master',
compare: '0123456..1234567',
finishedAt: '3 minutes ago',
duration: '30 sec',
message: 'commit message 1'
});
displaysTabs({
current: {
href: '#!/travis-ci/travis-core',
active: true
},
builds: {
href: '#!/travis-ci/travis-core/builds'
},
build: {
hidden: true
},
job: {
hidden: true
}
});
displaysJobMatrix({
element: '#jobs',
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
jobs: [
{
id: 1,
number: '1.1',
repo: 'travis-ci/travis-core',
finishedAt: '3 minutes ago',
duration: '30 sec',
rvm: 'rbx'
}, {
id: 2,
number: '1.2',
repo: 'travis-ci/travis-core',
finishedAt: '2 minutes ago',
duration: '40 sec',
rvm: '1.9.3'
}
]
});
return displaysJobMatrix({
element: '#allowed_failure_jobs',
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
jobs: [
{
id: 3,
number: '1.3',
repo: 'travis-ci/travis-core',
finishedAt: '-',
duration: '-',
rvm: 'jruby'
}
]
});
});
});
}).call(this);
(function() {
}).call(this);
(function() {
describe('on the "index" state', function() {
beforeEach(function() {
app('');
return waitFor(buildRendered);
});
return it('displays the expected stuff', function() {
displaysReposList([
{
slug: 'travis-ci/travis-core',
build: {
number: 1,
url: '#!/travis-ci/travis-core/builds/1',
duration: '30 sec',
finishedAt: '3 minutes ago'
}
}, {
slug: 'travis-ci/travis-assets',
build: {
number: 3,
url: '#!/travis-ci/travis-assets/builds/3',
duration: '30 sec',
finishedAt: 'a day ago'
}
}, {
slug: 'travis-ci/travis-hub',
build: {
number: 4,
url: '#!/travis-ci/travis-hub/builds/4',
duration: '1 min',
finishedAt: '-'
}
}
]);
displaysRepository({
href: 'http://github.com/travis-ci/travis-core'
});
displaysSummary({
type: 'build',
id: 1,
repo: 'travis-ci/travis-core',
commit: '1234567',
branch: 'master',
compare: '0123456..1234567',
finishedAt: '3 minutes ago',
duration: '30 sec',
message: 'commit message 1'
});
displaysTabs({
current: {
href: '#!/travis-ci/travis-core',
active: true
},
builds: {
href: '#!/travis-ci/travis-core/builds'
},
build: {
hidden: true
},
job: {
hidden: true
}
});
displaysJobMatrix({
element: '#jobs',
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
jobs: [
{
id: 1,
number: '1.1',
repo: 'travis-ci/travis-core',
finishedAt: '3 minutes ago',
duration: '30 sec',
rvm: 'rbx'
}, {
id: 2,
number: '1.2',
repo: 'travis-ci/travis-core',
finishedAt: '2 minutes ago',
duration: '40 sec',
rvm: '1.9.3'
}
]
});
return displaysJobMatrix({
element: '#allowed_failure_jobs',
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
jobs: [
{
id: 3,
number: '1.3',
repo: 'travis-ci/travis-core',
finishedAt: '-',
duration: '-',
rvm: 'jruby'
}
]
});
});
});
}).call(this);
(function() {
describe('on the "job" state', function() {
beforeEach(function() {
app('!/travis-ci/travis-core/jobs/1');
waitFor(jobRendered);
return waitFor(hasText('#tab_build', 'Build #1'));
});
return it('displays the expected stuff', function() {
displaysReposList([
{
slug: 'travis-ci/travis-core',
build: {
number: 1,
url: '#!/travis-ci/travis-core/builds/1',
duration: '30 sec',
finishedAt: '3 minutes ago'
}
}, {
slug: 'travis-ci/travis-assets',
build: {
number: 3,
url: '#!/travis-ci/travis-assets/builds/3',
duration: '30 sec',
finishedAt: 'a day ago'
}
}, {
slug: 'travis-ci/travis-hub',
build: {
number: 4,
url: '#!/travis-ci/travis-hub/builds/4',
duration: '1 min',
finishedAt: '-'
}
}
]);
displaysRepository({
href: 'http://github.com/travis-ci/travis-core'
});
displaysSummary({
id: 1,
type: 'job',
repo: 'travis-ci/travis-core',
commit: '1234567',
branch: 'master',
compare: '0123456..1234567',
finishedAt: '3 minutes ago',
duration: '30 sec',
message: 'commit message 1'
});
displaysTabs({
current: {
href: '#!/travis-ci/travis-core'
},
builds: {
href: '#!/travis-ci/travis-core/builds'
},
build: {
href: '#!/travis-ci/travis-core/builds/1'
},
job: {
href: '#!/travis-ci/travis-core/jobs/1',
active: true
}
});
return displaysLog(['log 1']);
});
});
@ -217,9 +393,12 @@
minispade.require('app');
this.reset = function() {
Em.run(function() {
if (Travis.app) {
Travis.app.destroy();
return Travis.app.destroy();
}
});
waits(500);
$('#content').remove();
return $('body').append('<div id="content"></div>');
};
@ -245,22 +424,32 @@
}).call(this);
(function() {
this.repositoriesRendered = function() {
return $('#repositories li a.current').text() !== '';
this.notEmpty = function(selector) {
return function() {
return $(selector).text().trim() !== '';
};
};
this.buildRendered = function() {
return $('#summary .number').text() !== '';
this.hasText = function(selector, text) {
return function() {
return $(selector).text().trim() === text;
};
};
this.matrixRendered = function() {
return $('#jobs').text() !== '';
};
this.reposRendered = notEmpty('#repositories li a.current');
this.buildRendered = notEmpty('#summary .number');
this.buildsRendered = notEmpty('#builds .number');
this.matrixRendered = notEmpty('#jobs');
this.jobRendered = notEmpty('#summary .number');
}).call(this);
(function() {
this.displaysRepoList = function(repos) {
this.displaysReposList = function(repos) {
var element, elements, ix, repo, _i, _len, _results;
elements = $('#repositories li').toArray();
ix = 0;
@ -282,19 +471,29 @@
};
this.displaysTabs = function(tabs) {
var tab, url, _i, _len, _results;
var name, tab, _results;
_results = [];
for (url = _i = 0, _len = tabs.length; _i < _len; url = ++_i) {
tab = tabs[url];
_results.push(expect($("#tab_" + tab + " a").attr('href')).toEqual(url));
for (name in tabs) {
tab = tabs[name];
if (!tab.hidden) {
expect($("#tab_" + name + " a").attr('href')).toEqual(tab.href);
}
expect($("#tab_" + name).hasClass('active')).toEqual(!!tab.active);
if (name === 'build' || name === 'job') {
_results.push(expect($("#tab_" + name).hasClass('display')).toEqual(!tab.hidden));
} else {
_results.push(void 0);
}
}
return _results;
};
this.displaysBuildSummary = function(data) {
this.displaysSummary = function(data) {
var element;
element = $('#summary .left:first-child dt:first-child');
expect(element.text()).toEqual($.camelize(data.type));
element = $('#summary .number a');
expect(element.attr('href')).toEqual("#!/" + data.repo + "/builds/" + data.id);
expect(element.attr('href')).toEqual("#!/" + data.repo + "/" + data.type + "s/" + data.id);
element = $('#summary .finished_at');
expect(element.text()).toEqual(data.finishedAt);
element = $('#summary .duration');
@ -339,6 +538,34 @@
});
};
this.displaysBuildsList = function(builds) {
var build, ix, row, rows, _i, _len, _results;
rows = $('#builds tbody tr').toArray();
ix = 0;
_results = [];
for (_i = 0, _len = builds.length; _i < _len; _i++) {
build = builds[_i];
row = rows[ix];
expect($('.number a', row).attr('href')).toEqual("#!/" + build.slug + "/builds/" + build.id);
expect($('.number a', row).text()).toEqual(build.number);
expect($('.message', row).text()).toEqual(build.message);
expect($('.duration', row).text()).toEqual(build.duration);
expect($('.finished_at', row).text()).toEqual(build.finishedAt);
_results.push(ix += 1);
}
return _results;
};
this.displaysLog = function(lines) {
var ix, log;
ix = 0;
log = $.map(lines, function(line) {
ix += 1;
return "" + ix + line;
}).join("\n");
return expect($('#log').text().trim()).toEqual(log);
};
}).call(this);
(function() {

View File

@ -21,7 +21,7 @@
var console_reporter = new jasmine.ConsoleReporter()
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
jasmine.getEnv().addReporter(console_reporter);
/* jasmine.getEnv().addReporter(console_reporter); */
jasmine.getEnv().execute();
</script>
</body>