add some more specs
This commit is contained in:
parent
932219f377
commit
f02eb6afbc
|
@ -1,10 +1,12 @@
|
|||
$.mockjaxSettings.log = false
|
||||
|
||||
@Travis = Em.Namespace.create
|
||||
App: Em.Application.extend
|
||||
initialize: ->
|
||||
initialize: (router) ->
|
||||
$.extend(this, Travis.Controllers)
|
||||
$.extend(this, Travis.Views)
|
||||
@store = Travis.Store.create()
|
||||
@_super(Travis.Router.create())
|
||||
@_super(router || Travis.Router.create())
|
||||
|
||||
run: ->
|
||||
@app = Travis.App.create()
|
||||
|
|
|
@ -29,6 +29,10 @@ require 'travis/model'
|
|||
Travis.Job.findMany(@getPath('data.job_ids') || [])
|
||||
).property('data.job_ids.length')
|
||||
|
||||
isMatrix: (->
|
||||
@getPath('data.job_ids.length') > 1
|
||||
).property('data.job_ids.length')
|
||||
|
||||
configKeys: (->
|
||||
config = @get('config')
|
||||
return [] unless config
|
||||
|
|
|
@ -16,7 +16,7 @@ require 'models'
|
|||
|
||||
find: (store, type, id) ->
|
||||
url = '/' + type.buildURL(id)
|
||||
console.log "find: #{url}"
|
||||
# console.log "find: #{url}"
|
||||
|
||||
@ajax url, 'GET',
|
||||
success: (json) ->
|
||||
|
@ -28,7 +28,7 @@ require 'models'
|
|||
|
||||
findMany: (store, type, ids) ->
|
||||
url = '/' + type.buildURL()
|
||||
console.log "findMany: #{url}"
|
||||
# console.log "findMany: #{url}"
|
||||
|
||||
@ajax url, 'GET',
|
||||
data:
|
||||
|
@ -42,7 +42,7 @@ require 'models'
|
|||
|
||||
findAll: (store, type) ->
|
||||
url = '/' + type.buildURL()
|
||||
console.log "findAll: #{url}"
|
||||
# console.log "findAll: #{url}"
|
||||
|
||||
@ajax url, 'GET',
|
||||
success: (json) ->
|
||||
|
@ -54,7 +54,7 @@ require 'models'
|
|||
|
||||
findQuery: (store, type, query, recordArray) ->
|
||||
url = '/' + type.buildURL()
|
||||
console.log "findQuery: #{url} (#{query})"
|
||||
# console.log "findQuery: #{url} (#{query})"
|
||||
|
||||
@ajax url, 'GET',
|
||||
data: query,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div {{bindAttr class="classes"}}>
|
||||
<div id="build" {{bindAttr class="classes"}}>
|
||||
<dl class="summary clearfix">
|
||||
<div class="left">
|
||||
<dt>{{t builds.name}}</dt>
|
||||
|
@ -11,10 +11,10 @@
|
|||
|
||||
<div class="right">
|
||||
<dt>{{t builds.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 builds.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 builds.author}}</dt>
|
||||
|
@ -27,7 +27,7 @@
|
|||
</div>
|
||||
|
||||
<dt>{{t builds.message}}</dt>
|
||||
<dd class="commit-message">{{{formatMessage commit.message}}}</dd>
|
||||
<dd class="message">{{{formatMessage commit.message}}}</dd>
|
||||
|
||||
{{#unless isMatrix}}
|
||||
<dt>{{t builds.config}}</dt>
|
||||
|
@ -36,7 +36,7 @@
|
|||
</dl>
|
||||
|
||||
{{#if isLoaded}}
|
||||
{{#if view.isMatrix}}
|
||||
{{#if isMatrix}}
|
||||
{{view Travis.Views.JobsView jobsBinding="view.requiredJobs" required="true"}}
|
||||
{{view Travis.Views.JobsView jobsBinding="view.allowedFailureJobs"}}
|
||||
{{else}}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
{{#each repository in content}}
|
||||
{{#view Travis.Views.RepositoriesItemView tagName="li" classBinding="classes" contextBinding="repository"}}
|
||||
<div class="wrapper">
|
||||
<a {{action viewCurrent href=true}} class="slug">{{slug}}</a>
|
||||
<a {{action viewBuild href=true context="lastBuild"}} class="build">#{{lastBuildNumber}}</a>
|
||||
<a {{action viewCurrent href=true}} class="current">{{slug}}</a>
|
||||
<a {{action viewBuild href=true context="lastBuild"}} class="last_build">#{{lastBuildNumber}}</a>
|
||||
</div>
|
||||
|
||||
<p class="summary">
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
<h3>
|
||||
<a {{bindAttr href="urlGithub"}}>{{slug}}</a>
|
||||
</h3>
|
||||
<div id="repository">
|
||||
<h3>
|
||||
<a {{bindAttr href="urlGithub"}}>{{slug}}</a>
|
||||
</h3>
|
||||
|
||||
<p class="description">{{description}}</p>
|
||||
<p class="description">{{description}}</p>
|
||||
|
||||
<ul class="github-stats">
|
||||
<li class="language">{{last_build_language}}</li>
|
||||
<li><a class="watchers" title="Watches" {{bindAttr href="urlGithubWatchers"}}>{{stats.watchers}}</a></li>
|
||||
<li><a class="forks" title="Forks" {{bindAttr href="urlGithubNetwork"}}>{{stats.forks}}</a></li>
|
||||
</ul>
|
||||
<ul class="github-stats">
|
||||
<li class="language">{{last_build_language}}</li>
|
||||
<li><a class="watchers" title="Watches" {{bindAttr href="urlGithubWatchers"}}>{{stats.watchers}}</a></li>
|
||||
<li><a class="forks" title="Forks" {{bindAttr href="urlGithubNetwork"}}>{{stats.forks}}</a></li>
|
||||
</ul>
|
||||
|
||||
{{outlet tabs}}
|
||||
{{outlet tabs}}
|
||||
|
||||
<div class="tab">
|
||||
{{outlet tab}}
|
||||
<div class="tab">
|
||||
{{outlet tab}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -40,10 +40,6 @@ Travis.Views =
|
|||
Helpers.colorForResult(@get('result'))
|
||||
).property('result')
|
||||
|
||||
isMatrix: (->
|
||||
@getPath('context.data.job_ids.length') > 1
|
||||
).property() # TODO if i bind this to 'context.data.job_ids.length', that breaks the entire view (as if context was always undefined)
|
||||
|
||||
requiredJobs: (->
|
||||
@getPath('context.jobs').filter((job) -> job.get('allow_failure') != true)
|
||||
).property() # TODO same here with binding to 'context.data.job_ids'
|
||||
|
|
|
@ -7,23 +7,23 @@ repositories = [
|
|||
builds = [
|
||||
{ id: 1, repository_id: 'travis-ci/travis-core', commit_id: 1, job_ids: [1, 2], number: 1, event_type: 'push', config: { rvm: ['rbx', '1.9.3'] }, finished_at: '2012-06-20T00:21:20Z', duration: 35, result: 0 },
|
||||
{ id: 2, repository_id: 'travis-ci/travis-core', commit_id: 2, job_ids: [3], number: 2, event_type: 'push', config: { rvm: ['rbx'] } },
|
||||
{ id: 3, repository_id: 'travis-ci/travis-assets', commit_id: 3, job_ids: [4], number: 3, event_type: 'push', config: { rvm: ['rbx'] } },
|
||||
{ id: 3, repository_id: 'travis-ci/travis-assets', commit_id: 3, job_ids: [4], number: 3, event_type: 'push', config: { rvm: ['rbx'] }, finished_at: '2012-06-20T00:21:20Z', duration: 35, result: 0 },
|
||||
{ id: 4, repository_id: 'travis-ci/travis-hub', commit_id: 4, job_ids: [5], number: 4, event_type: 'push', config: { rvm: ['rbx'] } },
|
||||
]
|
||||
|
||||
commits = [
|
||||
{ id: 1, sha: '1234567', branch: 'master', message: 'commit message 1', author_name: 'author name', author_email: 'author@email.com', compare_url: 'http://github.com/compare/012345..123456' },
|
||||
{ id: 2, sha: '2345678', branch: 'feature', message: 'commit message 2', author_name: 'author name', author_email: 'author@email.com', compare_url: 'http://github.com/compare/012345..123456' },
|
||||
{ id: 3, sha: '3456789', branch: 'master', message: 'commit message 3', author_name: 'author name', author_email: 'author@email.com', compare_url: 'http://github.com/compare/012345..123456' },
|
||||
{ id: 4, sha: '4567890', branch: 'master', message: 'commit message 4', author_name: 'author name', author_email: 'author@email.com', compare_url: 'http://github.com/compare/012345..123456' },
|
||||
{ id: 1, sha: '1234567', branch: 'master', message: 'commit message 1', author_name: 'author name', author_email: 'author@email.com', compare_url: 'http://github.com/compare/0123456..1234567' },
|
||||
{ id: 2, sha: '2345678', branch: 'feature', message: 'commit message 2', author_name: 'author name', author_email: 'author@email.com', compare_url: 'http://github.com/compare/0123456..2345678' },
|
||||
{ id: 3, sha: '3456789', branch: 'master', message: 'commit message 3', author_name: 'author name', author_email: 'author@email.com', compare_url: 'http://github.com/compare/0123456..3456789' },
|
||||
{ id: 4, sha: '4567890', branch: 'master', message: 'commit message 4', author_name: 'author name', author_email: 'author@email.com', compare_url: 'http://github.com/compare/0123456..4567890' },
|
||||
]
|
||||
|
||||
jobs = [
|
||||
{ id: 1, repository_id: 1, build_id: 1, commit_id: 1, log_id: 1, number: '1.1', config: { rvm: 'rbx' }, finished_at: '2012-06-20T00:21:20Z', duration: 35, result: 0 }
|
||||
{ id: 2, repository_id: 1, build_id: 1, commit_id: 1, log_id: 2, number: '1.2', config: { rvm: '1.9.3' } }
|
||||
{ id: 3, repository_id: 1, build_id: 2, commit_id: 2, log_id: 3, number: '2.1' }
|
||||
{ id: 4, repository_id: 2, build_id: 3, commit_id: 3, log_id: 4, number: '3.1' }
|
||||
{ id: 5, repository_id: 3, build_id: 4, commit_id: 4, log_id: 5, number: '4.1' }
|
||||
{ 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' }, finished_at: '2012-06-20T00:21:20Z', duration: 35, result: 0 }
|
||||
{ id: 5, repository_id: 3, build_id: 4, commit_id: 4, log_id: 5, number: '4.1', config: { rvm: 'rbx' } }
|
||||
]
|
||||
|
||||
artifacts = [
|
49
assets/javascripts/spec/current_spec.coffee
Normal file
49
assets/javascripts/spec/current_spec.coffee
Normal file
|
@ -0,0 +1,49 @@
|
|||
describe 'The current build tab', ->
|
||||
describe 'on the "index" state', ->
|
||||
beforeEach ->
|
||||
app '/'
|
||||
waitFor buildRendered
|
||||
|
||||
it 'displays the build summary', ->
|
||||
displaysBuildSummary
|
||||
id: 1
|
||||
repo: 'travis-ci/travis-core'
|
||||
commit: '1234567'
|
||||
branch: 'master'
|
||||
compare: '0123456..1234567'
|
||||
duration: '35 sec'
|
||||
message: 'commit message 1'
|
||||
|
||||
describe 'given the current build has a job matrix', ->
|
||||
it 'displays the build matrix table', ->
|
||||
displaysBuildMatrix
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm']
|
||||
jobs: [
|
||||
{ number: '#1.1', repo: 'travis-ci/travis-core', finishedAt: /\d+ (\w+) ago/, duration: '35 sec', rvm: 'rbx' },
|
||||
{ number: '#1.2', repo: 'travis-ci/travis-core', finishedAt: '-', duration: '-', rvm: '1.9.3' }
|
||||
]
|
||||
|
||||
describe 'on the "current" state', ->
|
||||
beforeEach ->
|
||||
app '/travis-ci/travis-core'
|
||||
waitFor repositoriesRendered
|
||||
waitFor buildRendered
|
||||
|
||||
it 'displays the build summary', ->
|
||||
displaysBuildSummary
|
||||
id: 1
|
||||
repo: 'travis-ci/travis-core'
|
||||
commit: '1234567'
|
||||
branch: 'master'
|
||||
compare: '0123456..1234567'
|
||||
duration: '35 sec'
|
||||
message: 'commit message 1'
|
||||
|
||||
describe 'given the current build has a job matrix', ->
|
||||
it 'displays the build matrix table', ->
|
||||
displaysBuildMatrix
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm']
|
||||
jobs: [
|
||||
{ number: '#1.1', repo: 'travis-ci/travis-core', finishedAt: /\d+ (\w+) ago/, duration: '35 sec', rvm: 'rbx' },
|
||||
{ number: '#1.2', repo: 'travis-ci/travis-core', finishedAt: '-', duration: '-', rvm: '1.9.3' }
|
||||
]
|
|
@ -1,13 +0,0 @@
|
|||
describe 'Foo', ->
|
||||
beforeEach ->
|
||||
createApp()
|
||||
waitFor repositoriesRendered
|
||||
|
||||
it 'bar', ->
|
||||
href = $('#repositories a.slug').attr('href')
|
||||
expect(href).toEqual '#/travis-ci/travis-core'
|
||||
|
||||
it 'bar', ->
|
||||
href = $('#repositories a.slug').attr('href')
|
||||
expect(href).toEqual '#/travis-ci/travis-core'
|
||||
|
13
assets/javascripts/spec/repositories_spec.coffee
Normal file
13
assets/javascripts/spec/repositories_spec.coffee
Normal file
|
@ -0,0 +1,13 @@
|
|||
describe 'The repositories list', ->
|
||||
beforeEach ->
|
||||
app '/'
|
||||
waitFor repositoriesRendered
|
||||
|
||||
it 'lists repositories', ->
|
||||
href = $('#repositories a.slug').attr('href')
|
||||
expect(href).toEqual '#/travis-ci/travis-core'
|
||||
|
||||
it "links to the repository's last build action", ->
|
||||
href = $('#repositories a.last_build').attr('href')
|
||||
expect(href).toEqual '#/travis-ci/travis-core/builds/1'
|
||||
|
8
assets/javascripts/spec/repository_spec.coffee
Normal file
8
assets/javascripts/spec/repository_spec.coffee
Normal file
|
@ -0,0 +1,8 @@
|
|||
describe 'The repository view', ->
|
||||
beforeEach ->
|
||||
app '/'
|
||||
waitFor repositoriesRendered
|
||||
|
||||
it 'displays the repository header', ->
|
||||
href = $('#repository h3 a').attr('href')
|
||||
expect(href).toEqual 'http://github.com/travis-ci/travis-core'
|
|
@ -1,26 +1,18 @@
|
|||
minispade.require 'app'
|
||||
|
||||
@after = (time, func) ->
|
||||
waits(time)
|
||||
jasmine.getEnv().currentSpec.runs(func)
|
||||
|
||||
@once = (condition, func) ->
|
||||
waitsFor(condition)
|
||||
jasmine.getEnv().currentSpec.runs(func)
|
||||
|
||||
@reset = ->
|
||||
Travis.app.destroy() if Travis.app
|
||||
$('body #content').empty()
|
||||
|
||||
@createApp = ->
|
||||
@app = (url) ->
|
||||
router = Travis.Router.create
|
||||
location: Em.NoneLocation.create()
|
||||
|
||||
Travis.app = Travis.App.create()
|
||||
Travis.app.set('rootElement', '#content')
|
||||
Travis.app.initialize()
|
||||
Travis.app.initialize(router)
|
||||
|
||||
@waitFor = waitsFor
|
||||
|
||||
@repositoriesRendered = ->
|
||||
$('#repositories li').length > 0
|
||||
router.route(url)
|
||||
|
||||
beforeEach ->
|
||||
reset()
|
||||
|
|
10
assets/javascripts/spec/support/conditions.coffee
Normal file
10
assets/javascripts/spec/support/conditions.coffee
Normal file
|
@ -0,0 +1,10 @@
|
|||
@repositoriesRendered = ->
|
||||
$('#repositories li').length > 0
|
||||
|
||||
@buildRendered = ->
|
||||
$('#build .summary .number').text() != ''
|
||||
|
||||
@matrixRendered = ->
|
||||
$('#jobs').text() != ''
|
||||
|
||||
|
52
assets/javascripts/spec/support/expectations.coffee
Normal file
52
assets/javascripts/spec/support/expectations.coffee
Normal file
|
@ -0,0 +1,52 @@
|
|||
@displaysBuildSummary = (data) ->
|
||||
element = $('#build .summary .number a')
|
||||
expect(element.attr('href')).toEqual "#/#{data.repo}/builds/#{data.id}"
|
||||
|
||||
element = $('#build .summary .finished_at')
|
||||
expect(element.text()).toMatch /\d+ (\w+) ago/
|
||||
|
||||
element = $('#build .summary .duration')
|
||||
expect(element.text()).toEqual data.duration
|
||||
|
||||
element = $('#build .summary .commit a')
|
||||
expect(element.attr('href')).toEqual "http://github.com/#{data.repo}/commit/#{data.commit}"
|
||||
|
||||
element = $('#build .summary .commit a')
|
||||
expect(element.text()).toEqual "#{data.commit} (#{data.branch})"
|
||||
|
||||
element = $('#build .summary .compare a')
|
||||
expect(element.attr('href')).toEqual "http://github.com/compare/#{data.compare}"
|
||||
|
||||
element = $('#build .summary .compare a')
|
||||
expect(element.text()).toEqual data.compare
|
||||
|
||||
element = $('#build .summary .message')
|
||||
expect(element.text()).toEqual data.message
|
||||
|
||||
@displaysBuildMatrix = (data) ->
|
||||
headers = ($(element).text() for element in $('#jobs thead th'))
|
||||
expect(headers).toEqual(data.headers)
|
||||
|
||||
$.each data.jobs, (ix, job) ->
|
||||
ix = (ix + 1) * 3 # cuz metamorph is adding two script elements
|
||||
|
||||
element = $("#jobs tr:nth-child(#{ix}) td.number")
|
||||
expect(element.text()).toEqual job.number
|
||||
|
||||
element = $("#jobs tr:nth-child(#{ix}) td.number a")
|
||||
expect(element.attr('href')).toEqual "#/#{job.repo}/jobs/#{job.id}"
|
||||
|
||||
element = $("#jobs tr:nth-child(#{ix}) td.duration")
|
||||
expect(element.text()).toEqual job.duration
|
||||
|
||||
element = $("#jobs tr:nth-child(#{ix}) td.finished_at")
|
||||
if job.finishedAt == '-'
|
||||
expect(element.text()).toEqual '-'
|
||||
else
|
||||
expect(element.text()).toMatch job.finishedAt
|
||||
|
||||
element = $("#jobs tr:nth-child(#{ix}) td:nth-child(6)")
|
||||
expect(element.text()).toEqual job.rvm
|
||||
|
||||
|
||||
|
11
assets/javascripts/spec/support/helpers.coffee
Normal file
11
assets/javascripts/spec/support/helpers.coffee
Normal file
|
@ -0,0 +1,11 @@
|
|||
@after = (time, func) ->
|
||||
waits(time)
|
||||
jasmine.getEnv().currentSpec.runs(func)
|
||||
|
||||
@once = (condition, func) ->
|
||||
waitsFor(condition)
|
||||
jasmine.getEnv().currentSpec.runs(func)
|
||||
|
||||
@waitFor = waitsFor
|
||||
|
||||
|
23
assets/javascripts/spec/tabs_spec.coffee
Normal file
23
assets/javascripts/spec/tabs_spec.coffee
Normal file
|
@ -0,0 +1,23 @@
|
|||
# describe 'The tabs view', ->
|
||||
# describe 'on the "index" state', ->
|
||||
# beforeEach ->
|
||||
# app '/'
|
||||
# waitFor repositoriesRendered
|
||||
#
|
||||
# it 'has a "current" tab linking to the current build', ->
|
||||
# href = $('#main .tabs a.current').attr('href')
|
||||
# expect(href).toEqual '/travis-ci/travis-core'
|
||||
#
|
||||
# it 'has a "history" tab linking to the builds list', ->
|
||||
# href = $('#main .tabs a.history').attr('href')
|
||||
# expect(href).toEqual '/travis-ci/travis-core/builds'
|
||||
#
|
||||
# describe 'on the "current" state', ->
|
||||
# app '/travis-ci/travis-core'
|
||||
# waitFor repositoriesRendered
|
||||
#
|
||||
# it 'has a "current" tab linking to the current build', ->
|
||||
# href = $('#main .tabs a.current').attr('href')
|
||||
# expect(href).toEqual '/travis-ci/travis-core'
|
||||
#
|
||||
#
|
|
@ -25,7 +25,6 @@ body {
|
|||
|
||||
#left, #main {
|
||||
float: left;
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
#left {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -63,7 +63,10 @@
|
|||
event_type: 'push',
|
||||
config: {
|
||||
rvm: ['rbx']
|
||||
}
|
||||
},
|
||||
finished_at: '2012-06-20T00:21:20Z',
|
||||
duration: 35,
|
||||
result: 0
|
||||
}, {
|
||||
id: 4,
|
||||
repository_id: 'travis-ci/travis-hub',
|
||||
|
@ -85,7 +88,7 @@
|
|||
message: 'commit message 1',
|
||||
author_name: 'author name',
|
||||
author_email: 'author@email.com',
|
||||
compare_url: 'http://github.com/compare/012345..123456'
|
||||
compare_url: 'http://github.com/compare/0123456..1234567'
|
||||
}, {
|
||||
id: 2,
|
||||
sha: '2345678',
|
||||
|
@ -93,7 +96,7 @@
|
|||
message: 'commit message 2',
|
||||
author_name: 'author name',
|
||||
author_email: 'author@email.com',
|
||||
compare_url: 'http://github.com/compare/012345..123456'
|
||||
compare_url: 'http://github.com/compare/0123456..2345678'
|
||||
}, {
|
||||
id: 3,
|
||||
sha: '3456789',
|
||||
|
@ -101,7 +104,7 @@
|
|||
message: 'commit message 3',
|
||||
author_name: 'author name',
|
||||
author_email: 'author@email.com',
|
||||
compare_url: 'http://github.com/compare/012345..123456'
|
||||
compare_url: 'http://github.com/compare/0123456..3456789'
|
||||
}, {
|
||||
id: 4,
|
||||
sha: '4567890',
|
||||
|
@ -109,7 +112,7 @@
|
|||
message: 'commit message 4',
|
||||
author_name: 'author name',
|
||||
author_email: 'author@email.com',
|
||||
compare_url: 'http://github.com/compare/012345..123456'
|
||||
compare_url: 'http://github.com/compare/0123456..4567890'
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -143,21 +146,33 @@
|
|||
build_id: 2,
|
||||
commit_id: 2,
|
||||
log_id: 3,
|
||||
number: '2.1'
|
||||
number: '2.1',
|
||||
config: {
|
||||
rvm: 'rbx'
|
||||
}
|
||||
}, {
|
||||
id: 4,
|
||||
repository_id: 2,
|
||||
build_id: 3,
|
||||
commit_id: 3,
|
||||
log_id: 4,
|
||||
number: '3.1'
|
||||
number: '3.1',
|
||||
config: {
|
||||
rvm: 'rbx'
|
||||
},
|
||||
finished_at: '2012-06-20T00:21:20Z',
|
||||
duration: 35,
|
||||
result: 0
|
||||
}, {
|
||||
id: 5,
|
||||
repository_id: 3,
|
||||
build_id: 4,
|
||||
commit_id: 4,
|
||||
log_id: 5,
|
||||
number: '4.1'
|
||||
number: '4.1',
|
||||
config: {
|
||||
rvm: 'rbx'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -1,19 +1,119 @@
|
|||
(function() {
|
||||
|
||||
describe('Foo', function() {
|
||||
describe('The current build tab', function() {
|
||||
describe('on the "index" state', function() {
|
||||
beforeEach(function() {
|
||||
app('/');
|
||||
return waitFor(buildRendered);
|
||||
});
|
||||
it('displays the build summary', function() {
|
||||
return displaysBuildSummary({
|
||||
id: 1,
|
||||
repo: 'travis-ci/travis-core',
|
||||
commit: '1234567',
|
||||
branch: 'master',
|
||||
compare: '0123456..1234567',
|
||||
duration: '35 sec',
|
||||
message: 'commit message 1'
|
||||
});
|
||||
});
|
||||
return describe('given the current build has a job matrix', function() {
|
||||
return it('displays the build matrix table', function() {
|
||||
return displaysBuildMatrix({
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
|
||||
jobs: [
|
||||
{
|
||||
number: '#1.1',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: /\d+ (\w+) ago/,
|
||||
duration: '35 sec',
|
||||
rvm: 'rbx'
|
||||
}, {
|
||||
number: '#1.2',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: '-',
|
||||
duration: '-',
|
||||
rvm: '1.9.3'
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
return describe('on the "current" state', function() {
|
||||
beforeEach(function() {
|
||||
app('/travis-ci/travis-core');
|
||||
waitFor(repositoriesRendered);
|
||||
return waitFor(buildRendered);
|
||||
});
|
||||
it('displays the build summary', function() {
|
||||
return displaysBuildSummary({
|
||||
id: 1,
|
||||
repo: 'travis-ci/travis-core',
|
||||
commit: '1234567',
|
||||
branch: 'master',
|
||||
compare: '0123456..1234567',
|
||||
duration: '35 sec',
|
||||
message: 'commit message 1'
|
||||
});
|
||||
});
|
||||
return describe('given the current build has a job matrix', function() {
|
||||
return it('displays the build matrix table', function() {
|
||||
return displaysBuildMatrix({
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
|
||||
jobs: [
|
||||
{
|
||||
number: '#1.1',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: /\d+ (\w+) ago/,
|
||||
duration: '35 sec',
|
||||
rvm: 'rbx'
|
||||
}, {
|
||||
number: '#1.2',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: '-',
|
||||
duration: '-',
|
||||
rvm: '1.9.3'
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
(function() {
|
||||
|
||||
describe('The repositories list', function() {
|
||||
beforeEach(function() {
|
||||
createApp();
|
||||
app('/');
|
||||
return waitFor(repositoriesRendered);
|
||||
});
|
||||
it('bar', function() {
|
||||
it('lists repositories', function() {
|
||||
var href;
|
||||
href = $('#repositories a.slug').attr('href');
|
||||
return expect(href).toEqual('#/travis-ci/travis-core');
|
||||
});
|
||||
return it('bar', function() {
|
||||
return it("links to the repository's last build action", function() {
|
||||
var href;
|
||||
href = $('#repositories a.slug').attr('href');
|
||||
return expect(href).toEqual('#/travis-ci/travis-core');
|
||||
href = $('#repositories a.last_build').attr('href');
|
||||
return expect(href).toEqual('#/travis-ci/travis-core/builds/1');
|
||||
});
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
(function() {
|
||||
|
||||
describe('The repository view', function() {
|
||||
beforeEach(function() {
|
||||
app('/');
|
||||
return waitFor(repositoriesRendered);
|
||||
});
|
||||
return it('displays the repository header', function() {
|
||||
var href;
|
||||
href = $('#repository h3 a').attr('href');
|
||||
return expect(href).toEqual('http://github.com/travis-ci/travis-core');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -22,6 +122,101 @@
|
|||
|
||||
minispade.require('app');
|
||||
|
||||
this.reset = function() {
|
||||
if (Travis.app) {
|
||||
Travis.app.destroy();
|
||||
}
|
||||
return $('body #content').empty();
|
||||
};
|
||||
|
||||
this.app = function(url) {
|
||||
var router;
|
||||
router = Travis.Router.create({
|
||||
location: Em.NoneLocation.create()
|
||||
});
|
||||
Travis.app = Travis.App.create();
|
||||
Travis.app.set('rootElement', '#content');
|
||||
Travis.app.initialize(router);
|
||||
return router.route(url);
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
return reset();
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
(function() {
|
||||
|
||||
this.repositoriesRendered = function() {
|
||||
return $('#repositories li').length > 0;
|
||||
};
|
||||
|
||||
this.buildRendered = function() {
|
||||
return $('#build .summary .number').text() !== '';
|
||||
};
|
||||
|
||||
this.matrixRendered = function() {
|
||||
return $('#jobs').text() !== '';
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
(function() {
|
||||
|
||||
this.displaysBuildSummary = function(data) {
|
||||
var element;
|
||||
element = $('#build .summary .number a');
|
||||
expect(element.attr('href')).toEqual("#/" + data.repo + "/builds/" + data.id);
|
||||
element = $('#build .summary .finished_at');
|
||||
expect(element.text()).toMatch(/\d+ (\w+) ago/);
|
||||
element = $('#build .summary .duration');
|
||||
expect(element.text()).toEqual(data.duration);
|
||||
element = $('#build .summary .commit a');
|
||||
expect(element.attr('href')).toEqual("http://github.com/" + data.repo + "/commit/" + data.commit);
|
||||
element = $('#build .summary .commit a');
|
||||
expect(element.text()).toEqual("" + data.commit + " (" + data.branch + ")");
|
||||
element = $('#build .summary .compare a');
|
||||
expect(element.attr('href')).toEqual("http://github.com/compare/" + data.compare);
|
||||
element = $('#build .summary .compare a');
|
||||
expect(element.text()).toEqual(data.compare);
|
||||
element = $('#build .summary .message');
|
||||
return expect(element.text()).toEqual(data.message);
|
||||
};
|
||||
|
||||
this.displaysBuildMatrix = function(data) {
|
||||
var element, headers;
|
||||
headers = (function() {
|
||||
var _i, _len, _ref, _results;
|
||||
_ref = $('#jobs thead th');
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
element = _ref[_i];
|
||||
_results.push($(element).text());
|
||||
}
|
||||
return _results;
|
||||
})();
|
||||
expect(headers).toEqual(data.headers);
|
||||
return $.each(data.jobs, function(ix, job) {
|
||||
ix = (ix + 1) * 3;
|
||||
element = $("#jobs tr:nth-child(" + ix + ") td.number");
|
||||
expect(element.text()).toEqual(job.number);
|
||||
element = $("#jobs tr:nth-child(" + ix + ") td.number a");
|
||||
expect(element.attr('href')).toEqual("#/" + job.repo + "/jobs/" + job.id);
|
||||
element = $("#jobs tr:nth-child(" + ix + ") td.duration");
|
||||
expect(element.text()).toEqual(job.duration);
|
||||
element = $("#jobs tr:nth-child(" + ix + ") td.finished_at");
|
||||
if (job.finishedAt === '-') {
|
||||
expect(element.text()).toEqual('-');
|
||||
} else {
|
||||
expect(element.text()).toMatch(job.finishedAt);
|
||||
}
|
||||
element = $("#jobs tr:nth-child(" + ix + ") td:nth-child(6)");
|
||||
return expect(element.text()).toEqual(job.rvm);
|
||||
});
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
(function() {
|
||||
|
||||
this.after = function(time, func) {
|
||||
waits(time);
|
||||
return jasmine.getEnv().currentSpec.runs(func);
|
||||
|
@ -32,27 +227,11 @@
|
|||
return jasmine.getEnv().currentSpec.runs(func);
|
||||
};
|
||||
|
||||
this.reset = function() {
|
||||
if (Travis.app) {
|
||||
Travis.app.destroy();
|
||||
}
|
||||
return $('body #content').empty();
|
||||
};
|
||||
|
||||
this.createApp = function() {
|
||||
Travis.app = Travis.App.create();
|
||||
Travis.app.set('rootElement', '#content');
|
||||
return Travis.app.initialize();
|
||||
};
|
||||
|
||||
this.waitFor = waitsFor;
|
||||
|
||||
this.repositoriesRendered = function() {
|
||||
return $('#repositories li').length > 0;
|
||||
};
|
||||
}).call(this);
|
||||
(function() {
|
||||
|
||||
|
||||
beforeEach(function() {
|
||||
return reset();
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -25,7 +25,6 @@ body {
|
|||
|
||||
#left, #main {
|
||||
float: left;
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
#left {
|
||||
|
|
Loading…
Reference in New Issue
Block a user