Rewrite specs from jasmine to qunit
This commit is contained in:
parent
5fea9d1d7b
commit
359c97cad0
|
@ -1,189 +0,0 @@
|
|||
describe 'events', ->
|
||||
describe 'an event adding a repository', ->
|
||||
beforeEach ->
|
||||
app 'travis-ci/travis-core'
|
||||
waitFor jobsRendered
|
||||
|
||||
it 'adds a repository to the list', ->
|
||||
waitFor reposRendered
|
||||
|
||||
runs ->
|
||||
payload =
|
||||
repository:
|
||||
id: 10
|
||||
build:
|
||||
id: 10
|
||||
repository_id: 10
|
||||
|
||||
$.mockjax
|
||||
url: '/builds/10'
|
||||
responseTime: 0
|
||||
responseText: payload
|
||||
|
||||
Em.run ->
|
||||
Travis.receive 'build:started',
|
||||
build:
|
||||
id: 10
|
||||
repository:
|
||||
id: 10
|
||||
slug: 'travis-ci/travis-support'
|
||||
last_build_id: 10
|
||||
last_build_number: 10
|
||||
last_build_started_at: '2012-07-02T00:01:00Z'
|
||||
last_build_finished_at: '2012-07-02T00:02:30Z'
|
||||
|
||||
waits(100)
|
||||
runs ->
|
||||
listsRepo
|
||||
row: 2
|
||||
item: { slug: 'travis-ci/travis-support', build: { number: 4, url: '/travis-ci/travis-support/builds/10', duration: '1 min 30 sec', finishedAt: 'less than a minute ago' } }
|
||||
|
||||
describe 'an event adding a build', ->
|
||||
beforeEach ->
|
||||
app 'travis-ci/travis-core/builds'
|
||||
waitFor buildsRendered
|
||||
|
||||
it 'adds a build to the builds list', ->
|
||||
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'
|
||||
message: 'commit message 3'
|
||||
commit: '1234567'
|
||||
state: 'failed'
|
||||
|
||||
Em.run ->
|
||||
Travis.receive 'build:started', payload
|
||||
|
||||
waits(100)
|
||||
runs ->
|
||||
listsBuild
|
||||
row: 1
|
||||
item: { id: 11, slug: 'travis-ci/travis-core', number: '3', sha: '1234567', branch: 'master', message: 'commit message 3', finishedAt: 'less than a minute ago', duration: '55 sec', color: 'red' }
|
||||
|
||||
describe 'an event adding a job', ->
|
||||
beforeEach ->
|
||||
app 'travis-ci/travis-core'
|
||||
waitFor jobsRendered, 'jobs should be rendered'
|
||||
#runs ->
|
||||
# waitFor queuesRendered, 'queues should be rendered'
|
||||
|
||||
#it 'adds a job to the jobs queue', ->
|
||||
# payload =
|
||||
# job:
|
||||
# id: 12
|
||||
# repository_id: 1
|
||||
# number: '1.4'
|
||||
# queue: 'builds.linux'
|
||||
|
||||
# $.mockjax
|
||||
# url: '/jobs/12'
|
||||
# responseTime: 0
|
||||
# responseText: payload
|
||||
|
||||
# Em.run ->
|
||||
# Travis.receive 'job:started',
|
||||
# job:
|
||||
# id: 12
|
||||
# repository_id: 1
|
||||
# repository_slug: 'travis-ci/travis-core'
|
||||
# number: '1.4'
|
||||
# queue: 'builds.linux'
|
||||
# state: 'created'
|
||||
|
||||
# waits(1000)
|
||||
# runs ->
|
||||
# listsQueuedJob
|
||||
# name: 'linux'
|
||||
# row: 3
|
||||
# item: { number: '1.4', repo: 'travis-ci/travis-core' }
|
||||
|
||||
it 'updates only keys that are available', ->
|
||||
Em.run ->
|
||||
Travis.receive 'job:started',
|
||||
job:
|
||||
id: 1
|
||||
build_id: 1
|
||||
|
||||
waits(100)
|
||||
runs ->
|
||||
listsJob
|
||||
table: $('#jobs')
|
||||
row: 1
|
||||
item: { id: 1, number: '1.1', repo: 'travis-ci/travis-core', finishedAt: '3 minutes ago', duration: '30 sec', rvm: 'rbx' }
|
||||
|
||||
#describe 'an event adding a worker', ->
|
||||
# beforeEach ->
|
||||
# app ''
|
||||
# waitFor sidebarTabsRendered
|
||||
# runs ->
|
||||
# $('#right #tab_workers a').trigger('click')
|
||||
# waitFor workersRendered
|
||||
|
||||
# it 'adds a worker to the workers list', ->
|
||||
# payload =
|
||||
# worker:
|
||||
# id: 10
|
||||
# host: 'worker.travis-ci.org'
|
||||
# name: 'ruby-3'
|
||||
# state: 'ready'
|
||||
|
||||
# $.mockjax
|
||||
# url: '/workers/10'
|
||||
# responseTime: 0
|
||||
# responseText: payload
|
||||
|
||||
# Em.run ->
|
||||
# Travis.receive 'worker:created',
|
||||
# worker:
|
||||
# id: 10
|
||||
# name: 'ruby-3'
|
||||
# host: 'worker.travis-ci.org'
|
||||
# state: 'ready'
|
||||
|
||||
# waits(100)
|
||||
# runs ->
|
||||
# listsWorker
|
||||
# group: 'worker.travis-ci.org'
|
||||
# row: 3
|
||||
# item: { name: 'ruby-3', state: 'ready' }
|
||||
|
||||
|
||||
#describe 'an event updating a worker', ->
|
||||
# beforeEach ->
|
||||
# app '/travis-ci/travis-core'
|
||||
# waitFor sidebarTabsRendered
|
||||
# runs ->
|
||||
# $('#right #tab_workers a').trigger('click')
|
||||
# waitFor workersRendered
|
||||
|
||||
# it 'does not update repository if it\'s already in the store', ->
|
||||
# payload =
|
||||
# worker:
|
||||
# id: 1
|
||||
# host: 'worker.travis-ci.org'
|
||||
# name: 'ruby-2'
|
||||
# state: 'working'
|
||||
# payload:
|
||||
# repository:
|
||||
# id: 1
|
||||
# last_build_id: 999
|
||||
# last_build_number: '999'
|
||||
|
||||
# Em.run ->
|
||||
# Travis.receive 'worker:updated', payload
|
||||
|
||||
# waits(100)
|
||||
# runs ->
|
||||
# listsRepo
|
||||
# row: 2
|
||||
# item: { slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
||||
|
||||
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
describe 'on the "build" state', ->
|
||||
beforeEach ->
|
||||
app '/travis-ci/travis-core/builds/1'
|
||||
module "Build page",
|
||||
setup: ->
|
||||
Ember.run -> Travis.advanceReadiness()
|
||||
teardown: ->
|
||||
Ember.run -> Travis.reset()
|
||||
|
||||
waitFor reposRendered
|
||||
runs ->
|
||||
waitFor buildRendered
|
||||
|
||||
it 'displays the expected stuff', ->
|
||||
test "displaying information on build page", ->
|
||||
visit('/travis-ci/travis-core/builds/1').then ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
||||
|
@ -48,14 +47,8 @@ describe 'on the "build" state', ->
|
|||
{ 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
|
||||
|
||||
it 'correctly updates values on pusher build:started event', ->
|
||||
test "updating current build", ->
|
||||
visit('/travis-ci/travis-core').then ->
|
||||
payload =
|
||||
build:
|
||||
id: 11
|
||||
|
@ -69,7 +62,11 @@ describe 'on the "current" state', ->
|
|||
result: 1
|
||||
message: 'commit message 3'
|
||||
commit: 'foo1234'
|
||||
branch: 'master'
|
||||
state: 'started'
|
||||
config: {}
|
||||
pull_request: false
|
||||
compare_url: 'http://github.com/compare/0123456..1234567'
|
||||
repository:
|
||||
id: 1
|
||||
last_build_number: '3'
|
||||
|
@ -78,8 +75,7 @@ describe 'on the "current" state', ->
|
|||
Em.run ->
|
||||
Travis.receive 'build:started', payload
|
||||
|
||||
waits 10
|
||||
runs ->
|
||||
wait().then ->
|
||||
displaysSummaryBuildLink '/travis-ci/travis-core/builds/11', '3'
|
||||
|
||||
displaysSummary
|
||||
|
@ -92,4 +88,3 @@ describe 'on the "current" state', ->
|
|||
finishedAt: 'less than a minute ago'
|
||||
duration: '55 sec'
|
||||
message: 'commit message 3'
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
describe 'on the "builds" state', ->
|
||||
beforeEach ->
|
||||
app '/travis-ci/travis-core/builds'
|
||||
waitFor buildsRendered
|
||||
module "Builds page",
|
||||
setup: ->
|
||||
Ember.run -> Travis.advanceReadiness()
|
||||
teardown: ->
|
||||
Ember.run -> Travis.reset()
|
||||
|
||||
it 'displays the expected stuff', ->
|
||||
test "displaying information on builds page", ->
|
||||
visit('/travis-ci/travis-core/builds').then ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
|
@ -1,9 +1,11 @@
|
|||
describe 'on the "current" state', ->
|
||||
beforeEach ->
|
||||
app 'travis-ci/travis-core'
|
||||
waitFor buildRendered
|
||||
module "Repo page",
|
||||
setup: ->
|
||||
Ember.run -> Travis.advanceReadiness()
|
||||
teardown: ->
|
||||
Ember.run -> Travis.reset()
|
||||
|
||||
it 'displays the expected stuff', ->
|
||||
test "displaying information on repo page", ->
|
||||
visit('travis-ci/travis-core').then ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
174
assets/scripts/spec/integration/event_spec.coffee
Normal file
174
assets/scripts/spec/integration/event_spec.coffee
Normal file
|
@ -0,0 +1,174 @@
|
|||
module "Events",
|
||||
setup: ->
|
||||
Ember.run -> Travis.advanceReadiness()
|
||||
teardown: ->
|
||||
Ember.run -> Travis.reset()
|
||||
|
||||
test "event containing a repository, adds repository to repos list", ->
|
||||
visit('travis-ci/travis-core').then ->
|
||||
payload =
|
||||
repository:
|
||||
id: 10
|
||||
build:
|
||||
id: 10
|
||||
repository_id: 10
|
||||
|
||||
$.mockjax
|
||||
url: '/builds/10'
|
||||
responseTime: 0
|
||||
responseText: payload
|
||||
|
||||
Em.run ->
|
||||
Travis.receive 'build:started',
|
||||
build:
|
||||
id: 10
|
||||
repository:
|
||||
id: 10
|
||||
slug: 'travis-ci/travis-support'
|
||||
last_build_id: 10
|
||||
last_build_number: 10
|
||||
last_build_started_at: '2012-07-02T00:01:00Z'
|
||||
last_build_finished_at: '2012-07-02T00:02:30Z'
|
||||
|
||||
wait().then ->
|
||||
listsRepo
|
||||
row: 2
|
||||
item: { slug: 'travis-ci/travis-support', build: { number: 4, url: '/travis-ci/travis-support/builds/10', duration: '1 min 30 sec', finishedAt: 'less than a minute ago' } }
|
||||
|
||||
test "an event with a build adds a build to a builds list", ->
|
||||
visit('travis-ci/travis-core/builds').then ->
|
||||
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'
|
||||
message: 'commit message 3'
|
||||
commit: '1234567'
|
||||
state: 'failed'
|
||||
|
||||
Em.run ->
|
||||
Travis.receive 'build:started', payload
|
||||
|
||||
wait().then ->
|
||||
listsBuild
|
||||
row: 1
|
||||
item: { id: 11, slug: 'travis-ci/travis-core', number: '3', sha: '1234567', branch: 'master', message: 'commit message 3', finishedAt: 'less than a minute ago', duration: '55 sec', color: 'red' }
|
||||
|
||||
#test "event containing a job, adds job to jobs list", ->
|
||||
# visit('travis-ci/travis-core').then ->
|
||||
# payload =
|
||||
# job:
|
||||
# id: 12
|
||||
# repository_id: 1
|
||||
# number: '1.4'
|
||||
# queue: 'builds.linux'
|
||||
#
|
||||
# $.mockjax
|
||||
# url: '/jobs/12'
|
||||
# responseTime: 0
|
||||
# responseText: payload
|
||||
#
|
||||
# Em.run ->
|
||||
# Travis.receive 'job:started',
|
||||
# job:
|
||||
# id: 12
|
||||
# repository_id: 1
|
||||
# repository_slug: 'travis-ci/travis-core'
|
||||
# number: '1.4'
|
||||
# queue: 'builds.linux'
|
||||
# state: 'created'
|
||||
#
|
||||
# wait().then ->
|
||||
# listsQueuedJob
|
||||
# name: 'linux'
|
||||
# row: 3
|
||||
# item: { number: '1.4', repo: 'travis-ci/travis-core' }
|
||||
#
|
||||
# it 'updates only keys that are available', ->
|
||||
# Em.run ->
|
||||
# Travis.receive 'job:started',
|
||||
# job:
|
||||
# id: 1
|
||||
# build_id: 1
|
||||
#
|
||||
# waits(100)
|
||||
# runs ->
|
||||
# listsJob
|
||||
# table: $('#jobs')
|
||||
# row: 1
|
||||
# item: { id: 1, number: '1.1', repo: 'travis-ci/travis-core', finishedAt: '3 minutes ago', duration: '30 sec', rvm: 'rbx' }
|
||||
#
|
||||
# #describe 'an event adding a worker', ->
|
||||
# # beforeEach ->
|
||||
# # app ''
|
||||
# # waitFor sidebarTabsRendered
|
||||
# # runs ->
|
||||
# # $('#right #tab_workers a').trigger('click')
|
||||
# # waitFor workersRendered
|
||||
#
|
||||
# # it 'adds a worker to the workers list', ->
|
||||
# # payload =
|
||||
# # worker:
|
||||
# # id: 10
|
||||
# # host: 'worker.travis-ci.org'
|
||||
# # name: 'ruby-3'
|
||||
# # state: 'ready'
|
||||
#
|
||||
# # $.mockjax
|
||||
# # url: '/workers/10'
|
||||
# # responseTime: 0
|
||||
# # responseText: payload
|
||||
#
|
||||
# # Em.run ->
|
||||
# # Travis.receive 'worker:created',
|
||||
# # worker:
|
||||
# # id: 10
|
||||
# # name: 'ruby-3'
|
||||
# # host: 'worker.travis-ci.org'
|
||||
# # state: 'ready'
|
||||
#
|
||||
# # waits(100)
|
||||
# # runs ->
|
||||
# # listsWorker
|
||||
# # group: 'worker.travis-ci.org'
|
||||
# # row: 3
|
||||
# # item: { name: 'ruby-3', state: 'ready' }
|
||||
#
|
||||
#
|
||||
# #describe 'an event updating a worker', ->
|
||||
# # beforeEach ->
|
||||
# # app '/travis-ci/travis-core'
|
||||
# # waitFor sidebarTabsRendered
|
||||
# # runs ->
|
||||
# # $('#right #tab_workers a').trigger('click')
|
||||
# # waitFor workersRendered
|
||||
#
|
||||
# # it 'does not update repository if it\'s already in the store', ->
|
||||
# # payload =
|
||||
# # worker:
|
||||
# # id: 1
|
||||
# # host: 'worker.travis-ci.org'
|
||||
# # name: 'ruby-2'
|
||||
# # state: 'working'
|
||||
# # payload:
|
||||
# # repository:
|
||||
# # id: 1
|
||||
# # last_build_id: 999
|
||||
# # last_build_number: '999'
|
||||
#
|
||||
# # Em.run ->
|
||||
# # Travis.receive 'worker:updated', payload
|
||||
#
|
||||
# # waits(100)
|
||||
# # runs ->
|
||||
# # listsRepo
|
||||
# # row: 2
|
||||
# # item: { slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
||||
#
|
||||
#
|
||||
#
|
|
@ -1,9 +1,11 @@
|
|||
describe 'on the "index" state', ->
|
||||
beforeEach ->
|
||||
app 'travis-ci/travis-core'
|
||||
waitFor buildRendered
|
||||
module "Index page",
|
||||
setup: ->
|
||||
Ember.run -> Travis.advanceReadiness()
|
||||
teardown: ->
|
||||
Ember.run -> Travis.reset()
|
||||
|
||||
it 'displays the expected stuff', ->
|
||||
test "displaying information on index page", ->
|
||||
visit('travis-ci/travis-core').then ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
81
assets/scripts/spec/integration/job_spec.coffee
Normal file
81
assets/scripts/spec/integration/job_spec.coffee
Normal file
|
@ -0,0 +1,81 @@
|
|||
module "Job page",
|
||||
setup: ->
|
||||
Ember.run -> Travis.advanceReadiness()
|
||||
teardown: ->
|
||||
Ember.run -> Travis.reset()
|
||||
|
||||
|
||||
test 'displaying information on job page', ->
|
||||
$.mockjax
|
||||
url: '/jobs/1/log?cors_hax=true'
|
||||
responseTime: 0
|
||||
responseText: "First line\ncontent:travis_fold:start:install\r$ Install something\nInstalling something\ncontent:travis_fold:end:install\r$ End"
|
||||
|
||||
visit('travis-ci/travis-core/jobs/1').then ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
{ 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' } }
|
||||
]
|
||||
|
||||
displaysRepository
|
||||
href: '/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 [
|
||||
'First line',
|
||||
'$ Install something',
|
||||
'Installing something',
|
||||
'$ End'
|
||||
]
|
||||
|
||||
# it 'allows to expand folds', ->
|
||||
# waits 100
|
||||
# runs ->
|
||||
# expect($('#fold-start-install').hasClass('open')).toBeFalsy()
|
||||
# $('#fold-start-install').click()
|
||||
# waits 20
|
||||
# runs ->
|
||||
# expect($('#fold-start-install').hasClass('open')).toBeTruthy()
|
||||
#
|
||||
#
|
||||
#describe 'too long log', ->
|
||||
# beforeEach ->
|
||||
# $.mockjax
|
||||
# url: '/jobs/2/log?cors_hax=true'
|
||||
# responseTime: 0
|
||||
# responseText: '1\n2\n3\n4\n5\n6\n7\n8\n9\n10'
|
||||
#
|
||||
# Log.LIMIT = 5
|
||||
#
|
||||
# app 'travis-ci/travis-core/jobs/2'
|
||||
# waitFor logRendered
|
||||
#
|
||||
# afterEach ->
|
||||
# Log.LIMIT = 10000
|
||||
#
|
||||
# it 'is cut after given limit', ->
|
||||
# displaysLog [
|
||||
# '12345'
|
||||
# ]
|
||||
#
|
||||
# expect( $('#log-container .warning').text() ).toMatch /This log is too long to be displayed/
|
||||
# expect( $('#log-container .warning a').attr('href') ).toEqual '/jobs/2/log.txt?deansi=true'
|
||||
#
|
||||
#
|
45
assets/scripts/spec/integration/my_repos_spec.coffee
Normal file
45
assets/scripts/spec/integration/my_repos_spec.coffee
Normal file
|
@ -0,0 +1,45 @@
|
|||
module "My repos",
|
||||
setup: ->
|
||||
Ember.run -> Travis.advanceReadiness()
|
||||
teardown: ->
|
||||
Ember.run -> Travis.reset()
|
||||
|
||||
test "my repos is active by default when user is signed in", ->
|
||||
|
||||
Ember.run -> signInUser()
|
||||
visit('/').then ->
|
||||
wait().then ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
||||
]
|
||||
|
||||
displaysRepository
|
||||
href: '/travis-ci/travis-hub'
|
||||
|
||||
displaysSummary
|
||||
type: 'build'
|
||||
id: 4
|
||||
repo: 'travis-ci/travis-hub'
|
||||
commit: '4567890'
|
||||
branch: 'master'
|
||||
compare: '0123456..4567890'
|
||||
finishedAt: '-'
|
||||
duration: '1 min'
|
||||
message: 'commit message 4'
|
||||
|
||||
test "my repos is activated when user signs in", ->
|
||||
visit('/').then ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
{ 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' } }
|
||||
]
|
||||
|
||||
Ember.run -> signInUser()
|
||||
|
||||
wait().then ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
||||
]
|
9
assets/scripts/spec/integration/routes_spec.coffee
Normal file
9
assets/scripts/spec/integration/routes_spec.coffee
Normal file
|
@ -0,0 +1,9 @@
|
|||
#module "Router",
|
||||
# setup: ->
|
||||
# Ember.run -> Travis.advanceReadiness()
|
||||
# teardown: ->
|
||||
# Ember.run -> Travis.reset()
|
||||
#
|
||||
#test 'renders notFound template when URL can\t be found', ->
|
||||
# visit('/somehing/something/something/.../dark/side/..../something/something/something/.../complete').then ->
|
||||
# equal('The requested page was not found.', $('#main').text().trim())
|
|
@ -1,83 +0,0 @@
|
|||
describe 'on the "job" state', ->
|
||||
beforeEach ->
|
||||
$.mockjax
|
||||
url: '/jobs/1/log?cors_hax=true'
|
||||
responseTime: 0
|
||||
responseText: "First line\ncontent:travis_fold:start:install\r$ Install something\nInstalling something\ncontent:travis_fold:end:install\r$ End"
|
||||
|
||||
|
||||
app 'travis-ci/travis-core/jobs/1'
|
||||
waitFor jobRendered
|
||||
runs ->
|
||||
waitFor hasText('#tab_build', 'Build #1')
|
||||
|
||||
it 'displays the expected stuff', ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
{ 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' } }
|
||||
]
|
||||
|
||||
waits 100
|
||||
runs ->
|
||||
displaysRepository
|
||||
href: '/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 [
|
||||
'First line',
|
||||
'$ Install something',
|
||||
'Installing something',
|
||||
'$ End'
|
||||
]
|
||||
|
||||
it 'allows to expand folds', ->
|
||||
waits 100
|
||||
runs ->
|
||||
expect($('#fold-start-install').hasClass('open')).toBeFalsy()
|
||||
$('#fold-start-install').click()
|
||||
waits 20
|
||||
runs ->
|
||||
expect($('#fold-start-install').hasClass('open')).toBeTruthy()
|
||||
|
||||
|
||||
describe 'too long log', ->
|
||||
beforeEach ->
|
||||
$.mockjax
|
||||
url: '/jobs/2/log?cors_hax=true'
|
||||
responseTime: 0
|
||||
responseText: '1\n2\n3\n4\n5\n6\n7\n8\n9\n10'
|
||||
|
||||
Log.LIMIT = 5
|
||||
|
||||
app 'travis-ci/travis-core/jobs/2'
|
||||
waitFor logRendered
|
||||
|
||||
afterEach ->
|
||||
Log.LIMIT = 10000
|
||||
|
||||
it 'is cut after given limit', ->
|
||||
displaysLog [
|
||||
'12345'
|
||||
]
|
||||
|
||||
expect( $('#log-container .warning').text() ).toMatch /This log is too long to be displayed/
|
||||
expect( $('#log-container .warning a').attr('href') ).toEqual '/jobs/2/log.txt?deansi=true'
|
||||
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
describe 'my repos tab', ->
|
||||
describe 'when user is signed in', ->
|
||||
beforeEach ->
|
||||
app '/', user: true
|
||||
waitFor myReposRendered, 'my repositories'
|
||||
runs ->
|
||||
waitFor buildRendered, 'build view'
|
||||
|
||||
it 'is active', ->
|
||||
listsRepos [
|
||||
{ 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-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
]
|
||||
|
||||
displaysRepository
|
||||
href: '/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'
|
||||
|
||||
describe 'when user is not signed in', ->
|
||||
beforeEach ->
|
||||
app '/'
|
||||
waitFor reposRendered, 'repositories list'
|
||||
runs ->
|
||||
waitFor buildRendered, 'build view'
|
||||
|
||||
it 'is activated when user signs in', ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
{ 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' } }
|
||||
]
|
||||
|
||||
signInUser()
|
||||
|
||||
waitFor myReposRendered, 'my repositories'
|
||||
runs ->
|
||||
waitFor buildRendered, 'build view'
|
||||
runs ->
|
||||
listsRepos [
|
||||
{ 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-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
]
|
|
@ -1,7 +0,0 @@
|
|||
describe 'router', ->
|
||||
it 'renders notFound template when URL can\t be found', ->
|
||||
app '/somehing/something/something/.../dark/side/..../something/something/something/.../complete'
|
||||
waitFor appRendered
|
||||
runs ->
|
||||
expect( $('#main').text().trim() ).toEqual('The requested page was not found.')
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#describe 'the sidebar', ->
|
||||
# beforeEach ->
|
||||
# app 'travis-ci/travis-core/jobs/1'
|
||||
# waitFor jobRendered
|
||||
# runs ->
|
||||
# waitFor hasText('#tab_build', 'Build #1')
|
||||
#
|
||||
# it 'displays the expected stuff', ->
|
||||
# listsQueues [
|
||||
# { name: 'linux', item: { number: '5.1', repo: 'travis-ci/travis-core' } }
|
||||
# { name: 'linux', item: { number: '5.2', repo: 'travis-ci/travis-core' } }
|
||||
# ]
|
|
@ -1,6 +1,22 @@
|
|||
minispade.require 'app'
|
||||
document.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
|
||||
|
||||
@signInUser = ->
|
||||
Travis.rootElement = '#ember-testing';
|
||||
Travis.setupForTesting();
|
||||
Travis.injectTestHelpers();
|
||||
|
||||
oldSetup = Travis.setup
|
||||
Travis.ready = ->
|
||||
oldSetup.apply(this, arguments)
|
||||
Travis.auth.signOut()
|
||||
|
||||
window.exists = (selector) ->
|
||||
return !!find(selector).length
|
||||
|
||||
Ember.Container.prototype.stub = (fullName, instance) ->
|
||||
instance.destroy = instance.destroy || (->)
|
||||
this.cache.dict[fullName] = instance
|
||||
|
||||
window.signInUser = ->
|
||||
# for now let's just use harcoded data to log in the user,
|
||||
# we may extend it in the future to pass specific user data
|
||||
Travis.auth.signIn
|
||||
|
@ -11,20 +27,19 @@ minispade.require 'app'
|
|||
token: 'abcdef'
|
||||
token: 'abcdef'
|
||||
|
||||
@app = (url, options = {}) ->
|
||||
# TODO: this should wait till app is initialized, not some
|
||||
# arbitrary amount of time
|
||||
waits(50)
|
||||
runs ->
|
||||
Travis.reset()
|
||||
Travis.auth.signOut()
|
||||
|
||||
if options.user
|
||||
signInUser()
|
||||
url = "/#{url}" unless url.match /^\//
|
||||
visit(url)
|
||||
#@app = (url, options = {}) ->
|
||||
# # TODO: this should wait till app is initialized, not some
|
||||
# # arbitrary amount of time
|
||||
# waits(50)
|
||||
# runs ->
|
||||
# Travis.reset()
|
||||
# Travis.auth.signOut()
|
||||
#
|
||||
# if options.user
|
||||
# signInUser()
|
||||
# url = "/#{url}" unless url.match /^\//
|
||||
# visit(url)
|
||||
|
||||
now = -> new Date('2012-07-02T00:03:00Z')
|
||||
$.timeago.settings.nowFunction = -> now().getTime()
|
||||
Travis.currentDate = now
|
||||
Travis.testing = true
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
@displaysRepository = (repo) ->
|
||||
expect($('#repo h3 a').attr('href')).toEqual (repo.href)
|
||||
expect($('#repo .github-icon a').attr('href')).toEqual ("http://github.com#{repo.href}")
|
||||
equal($('#repo h3 a').attr('href'), repo.href, 'repository title should link to repo page')
|
||||
equal($('#repo .github-icon a').attr('href'), "http://github.com#{repo.href}", 'github icon should link to repo on github')
|
||||
|
||||
@displaysTabs = (tabs) ->
|
||||
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-inline')).toEqual !tab.hidden if name in ['build', 'job']
|
||||
equal($("#tab_#{name} a").attr('href'), tab.href, "#{name} tab should link to #{tab.href}") unless tab.hidden
|
||||
equal($("#tab_#{name}").hasClass('active'), !!tab.active, "#{name} tab should be active")
|
||||
equal($("#tab_#{name}").hasClass('display-inline'), !tab.hidden, "#{name} tab should has class display-inline") if name in ['build', 'job']
|
||||
|
||||
@displaysSummaryBuildLink = (link, number) ->
|
||||
element = $('#summary .number a')
|
||||
expect( element.attr('href') ).toEqual link
|
||||
expect( element.text().trim() ).toEqual "#{number}"
|
||||
equal( element.attr('href') , link)
|
||||
equal( element.text().trim() , "#{number}")
|
||||
|
||||
@displaysSummary = (data) ->
|
||||
element = $('#summary .left:first-child dt:first-child')
|
||||
expect(element.text()).toEqual $.camelize(data.type)
|
||||
equal(element.text(), $.camelize(data.type))
|
||||
|
||||
element = $('#summary .number a')
|
||||
expect(element.attr('href')).toEqual "/#{data.repo}/#{data.type}s/#{data.id}"
|
||||
equal(element.attr('href'), "/#{data.repo}/#{data.type}s/#{data.id}")
|
||||
|
||||
element = $('#summary .finished_at')
|
||||
expect(element.text()).toEqual data.finishedAt
|
||||
equal(element.text(), data.finishedAt)
|
||||
|
||||
element = $('#summary .duration')
|
||||
expect(element.text()).toEqual data.duration
|
||||
equal(element.text(), data.duration)
|
||||
|
||||
element = $('#summary .commit a')
|
||||
expect(element.attr('href')).toEqual "http://github.com/#{data.repo}/commit/#{data.commit}"
|
||||
equal(element.attr('href'), "http://github.com/#{data.repo}/commit/#{data.commit}")
|
||||
|
||||
element = $('#summary .commit a')
|
||||
expect(element.text()).toEqual "#{data.commit} (#{data.branch})"
|
||||
equal(element.text(), "#{data.commit} (#{data.branch})")
|
||||
|
||||
element = $('#summary .compare a')
|
||||
expect(element.attr('href')).toEqual "http://github.com/compare/#{data.compare}"
|
||||
equal(element.attr('href'), "http://github.com/compare/#{data.compare}")
|
||||
|
||||
element = $('#summary .compare a')
|
||||
expect(element.text()).toEqual data.compare
|
||||
equal(element.text(), data.compare)
|
||||
|
||||
element = $('#summary .message')
|
||||
expect(element.text()).toEqual data.message
|
||||
equal(element.text(), data.message)
|
||||
|
||||
@displaysLog = (lines) ->
|
||||
log = lines.join('')
|
||||
expect($('#log p').text().trim()).toEqual log
|
||||
equal($('#log p').text().trim(), log)
|
||||
|
||||
@listsRepos = (items) ->
|
||||
listsItems('repo', items)
|
||||
|
@ -52,10 +52,10 @@
|
|||
row = $('#repos li')[data.row - 1]
|
||||
repo = data.item
|
||||
|
||||
expect($('a.slug', row).attr('href')).toEqual "/#{repo.slug}"
|
||||
expect($('a.last_build', row).attr('href')).toEqual repo.build.url
|
||||
expect($('.duration', row).text()).toEqual repo.build.duration
|
||||
expect($('.finished_at', row).text()).toEqual repo.build.finishedAt
|
||||
equal($('a.slug', row).attr('href'), "/#{repo.slug}")
|
||||
equal($('a.last_build', row).attr('href'), repo.build.url)
|
||||
equal($('.duration', row).text(), repo.build.duration)
|
||||
equal($('.finished_at', row).text(), repo.build.finishedAt)
|
||||
|
||||
@listsBuilds = (builds) ->
|
||||
listsItems('build', builds)
|
||||
|
@ -64,17 +64,17 @@
|
|||
row = $('#builds tbody tr')[data.row - 1]
|
||||
build = data.item
|
||||
|
||||
expect($('.number a', row).attr('href')).toEqual "/#{build.slug}/builds/#{build.id}"
|
||||
expect($('.number a', row).text().trim()).toEqual build.number
|
||||
expect($('.message', row).text().trim()).toEqual build.message
|
||||
expect($('.duration', row).text().trim()).toEqual build.duration
|
||||
expect($('.finished_at', row).text().trim()).toEqual build.finishedAt
|
||||
expect($(row).attr('class')).toMatch build.color
|
||||
equal($('.number a', row).attr('href'), "/#{build.slug}/builds/#{build.id}")
|
||||
equal($('.number a', row).text().trim(), build.number)
|
||||
equal($('.message', row).text().trim(), build.message)
|
||||
equal($('.duration', row).text().trim(), build.duration)
|
||||
equal($('.finished_at', row).text().trim(), build.finishedAt)
|
||||
ok($(row).attr('class').match(build.color))
|
||||
|
||||
@listsJobs = (data) ->
|
||||
table = $(data.table)
|
||||
headers = ($(element).text() for element in $("thead th", table))
|
||||
expect(headers).toEqual(data.headers)
|
||||
deepEqual(headers, data.headers)
|
||||
|
||||
$.each data.jobs, (row, job) -> listsJob(table: data.table, row: row + 1, item: job)
|
||||
|
||||
|
@ -83,22 +83,22 @@
|
|||
job = data.item
|
||||
|
||||
element = $(row)
|
||||
expect(element.attr('class')).toMatch job.color
|
||||
ok(element.attr('class').match(job.color))
|
||||
|
||||
element = $("td.number", row)
|
||||
expect(element.text().trim()).toEqual job.number
|
||||
equal(element.text().trim(), job.number)
|
||||
|
||||
element = $("td.number a", row)
|
||||
expect(element.attr('href')).toEqual "/#{job.repo}/jobs/#{job.id}"
|
||||
equal(element.attr('href'), "/#{job.repo}/jobs/#{job.id}")
|
||||
|
||||
element = $("td.duration", row)
|
||||
expect(element.text().trim()).toEqual job.duration
|
||||
equal(element.text().trim(), job.duration)
|
||||
|
||||
element = $("td.finished_at", row)
|
||||
expect(element.text().trim()).toEqual job.finishedAt
|
||||
equal(element.text().trim(), job.finishedAt)
|
||||
|
||||
element = $("td:nth-child(6)", row)
|
||||
expect(element.text().trim()).toEqual job.rvm
|
||||
equal(element.text().trim(), job.rvm)
|
||||
|
||||
@listsQueuedJobs = (jobs) ->
|
||||
listsItems('queuedJob', jobs)
|
||||
|
@ -106,19 +106,19 @@
|
|||
@listsQueuedJob = (data) ->
|
||||
job = data.item
|
||||
text = $($("#queue_#{data.name} li")[data.row - 1]).text()
|
||||
expect(text).toContain job.repo
|
||||
expect(text).toContain "##{job.number}"
|
||||
ok(text.match(job.repo), "#{text} should contain #{job.repo}")
|
||||
ok(text.match(job.repo), "#{text} should contain #{job.number}")
|
||||
|
||||
@listsQueue = (data) ->
|
||||
name = data.item.name
|
||||
job = data.item.item
|
||||
text = $($("#queue_#{name} li")[data.row - 1]).text()
|
||||
expect(text).toContain job.repo
|
||||
expect(text).toContain "##{job.number}"
|
||||
ok(text.match(job.repo), "#{text} should contain #{job.repo}")
|
||||
ok(text.match(job.repo), "#{text} should contain #{job.number}")
|
||||
|
||||
@listsItems = (type, items) ->
|
||||
$.each items, (row, item) =>
|
||||
this["lists#{$.camelize(type)}"](item: item, row: row + 1)
|
||||
window["lists#{$.camelize(type)}"](item: item, row: row + 1)
|
||||
|
||||
@listsQueues = (queues) ->
|
||||
listsItems('queue', queues)
|
||||
|
@ -128,5 +128,5 @@
|
|||
element = $($('ul li', group)[data.row - 1])
|
||||
worker = data.item
|
||||
|
||||
expect(element.text()).toContain worker.name
|
||||
expect(element.text()).toContain worker.state
|
||||
ok(element.text().match(worker.name))
|
||||
ok(element.text().match(worker.state))
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
@after = (time, func) ->
|
||||
waits(time)
|
||||
jasmine.getEnv().currentSpec.runs(func)
|
||||
|
||||
@once = (condition, func) ->
|
||||
waitsFor(condition)
|
||||
jasmine.getEnv().currentSpec.runs(func)
|
||||
|
||||
@waitFor = waitsFor
|
||||
|
||||
#@after = (time, func) ->
|
||||
# waits(time)
|
||||
# jasmine.getEnv().currentSpec.runs(func)
|
||||
#
|
||||
#@once = (condition, func) ->
|
||||
# waitsFor(condition)
|
||||
# jasmine.getEnv().currentSpec.runs(func)
|
||||
#
|
||||
#@waitFor = waitsFor
|
||||
#
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
minispade.require 'ext/jquery'
|
||||
|
||||
responseTime = 0
|
||||
|
||||
repos = [
|
||||
{ id: '1', owner: 'travis-ci', name: 'travis-core', slug: 'travis-ci/travis-core', build_ids: [1, 2], last_build_id: 1, last_build_number: 1, last_build_result: 0, last_build_duration: 30, last_build_started_at: '2012-07-02T00:00:00Z', last_build_finished_at: '2012-07-02T00:00:30Z', description: 'Description of travis-core' },
|
||||
{ id: '2', owner: 'travis-ci', name: 'travis-assets', slug: 'travis-ci/travis-assets', build_ids: [3], last_build_id: 3, last_build_number: 3, last_build_result: 1, last_build_duration: 30, last_build_started_at: '2012-07-02T00:01:00Z', last_build_finished_at: '2012-07-01T00:01:30Z', description: 'Description of travis-assets'},
|
||||
{ id: '3', owner: 'travis-ci', name: 'travis-hub', slug: 'travis-ci/travis-hub', build_ids: [4], last_build_id: 4, last_build_number: 4, last_build_result: undefined, last_build_duration: undefined, last_build_started_at: '2012-07-02T00:02:00Z', last_build_finished_at: undefined, description: 'Description of travis-hub'},
|
||||
{ id: '1', owner: 'travis-ci', name: 'travis-core', slug: 'travis-ci/travis-core', build_ids: [1, 2], last_build_id: 1, last_build_number: 1, last_build_state: 'passed', last_build_duration: 30, last_build_started_at: '2012-07-02T00:00:00Z', last_build_finished_at: '2012-07-02T00:00:30Z', description: 'Description of travis-core' },
|
||||
{ id: '2', owner: 'travis-ci', name: 'travis-assets', slug: 'travis-ci/travis-assets', build_ids: [3], last_build_id: 3, last_build_number: 3, last_build_state: 'failed', last_build_duration: 30, last_build_started_at: '2012-07-02T00:01:00Z', last_build_finished_at: '2012-07-01T00:01:30Z', description: 'Description of travis-assets'},
|
||||
{ id: '3', owner: 'travis-ci', name: 'travis-hub', slug: 'travis-ci/travis-hub', build_ids: [4], last_build_id: 4, last_build_number: 4, last_build_state: null, last_build_duration: null, last_build_started_at: '2012-07-02T00:02:00Z', last_build_finished_at: null, description: 'Description of travis-hub'},
|
||||
]
|
||||
|
||||
reposByName = (name) ->
|
||||
|
@ -16,9 +18,9 @@ reposByName = (name) ->
|
|||
|
||||
builds = [
|
||||
{ id: '1', repository_id: '1', commit_id: 1, job_ids: [1, 2, 3], number: 1, pull_request: false, config: { rvm: ['rbx', '1.9.3', 'jruby'] }, duration: 30, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:30Z', state: 'passed' },
|
||||
{ id: '2', repository_id: '1', commit_id: 2, job_ids: [4], number: 2, pull_request: false, config: { rvm: ['rbx'] } },
|
||||
{ id: '2', repository_id: '1', commit_id: 2, job_ids: [4], number: 2, pull_request: false, config: { rvm: ['rbx'] }, duration: null },
|
||||
{ id: '3', repository_id: '2', commit_id: 3, job_ids: [5], number: 3, pull_request: false, config: { rvm: ['rbx'] }, duration: 30, started_at: '2012-07-02T00:01:00Z', finished_at: '2012-07-01T00:01:30Z', state: 'failed' },
|
||||
{ id: '4', repository_id: '3', commit_id: 4, job_ids: [6], number: 4, pull_request: false, config: { rvm: ['rbx'] }, started_at: '2012-07-02T00:02:00Z' },
|
||||
{ id: '4', repository_id: '3', commit_id: 4, job_ids: [6], number: 4, pull_request: false, config: { rvm: ['rbx'] }, duration: null, started_at: '2012-07-02T00:02:00Z' },
|
||||
]
|
||||
|
||||
commits = [
|
||||
|
@ -29,14 +31,14 @@ commits = [
|
|||
]
|
||||
|
||||
jobs = [
|
||||
{ id: '1', repository_id: 1, repository_slug: 'travis-ci/travis-core', 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', state: 'passed' }
|
||||
{ id: '2', repository_id: 1, repository_slug: 'travis-ci/travis-core', 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', state: 'failed' }
|
||||
{ id: '3', repository_id: 1, repository_slug: 'travis-ci/travis-core', build_id: 1, commit_id: 1, log_id: 3, number: '1.3', config: { rvm: 'jruby' }, allow_failure: true }
|
||||
{ id: '4', repository_id: 1, repository_slug: 'travis-ci/travis-core', build_id: 2, commit_id: 2, log_id: 4, number: '2.1', config: { rvm: 'rbx' } }
|
||||
{ id: '5', repository_id: 2, repository_slug: 'travis-ci/travis-assets', 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', state: 'failed' }
|
||||
{ id: '6', repository_id: 3, repository_slug: 'travis-ci/travis-hub', 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, repository_slug: 'travis-ci/travis-core', build_id: 5, commit_id: 5, log_id: 7, number: '5.1', config: { rvm: 'rbx' }, state: 'created', queue: 'builds.linux' }
|
||||
{ id: '8', repository_id: 1, repository_slug: 'travis-ci/travis-core', build_id: 5, commit_id: 5, log_id: 8, number: '5.2', config: { rvm: 'rbx' }, state: 'created', queue: 'builds.linux' }
|
||||
{ id: '1', repository_id: 1, repository_slug: 'travis-ci/travis-core', 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', state: 'passed', allow_failure: false }
|
||||
{ id: '2', repository_id: 1, repository_slug: 'travis-ci/travis-core', 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', state: 'failed', allow_failure: false }
|
||||
{ id: '3', repository_id: 1, repository_slug: 'travis-ci/travis-core', build_id: 1, commit_id: 1, log_id: 3, number: '1.3', config: { rvm: 'jruby' }, duration: null, started_at: null, finished_at: null, allow_failure: true, state: null }
|
||||
{ id: '4', repository_id: 1, repository_slug: 'travis-ci/travis-core', build_id: 2, commit_id: 2, log_id: 4, number: '2.1', config: { rvm: 'rbx' }, duration: null, started_at: null, finished_at: null, allow_failure: false, state: null }
|
||||
{ id: '5', repository_id: 2, repository_slug: 'travis-ci/travis-assets', 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', state: 'failed', allow_failure: false }
|
||||
{ id: '6', repository_id: 3, repository_slug: 'travis-ci/travis-hub', build_id: 4, commit_id: 4, log_id: 6, number: '4.1', config: { rvm: 'rbx' }, started_at: '2012-07-02T00:02:00Z', allow_failure: false, state: null }
|
||||
{ id: '7', repository_id: 1, repository_slug: 'travis-ci/travis-core', build_id: 5, commit_id: 5, log_id: 7, number: '5.1', config: { rvm: 'rbx' }, duration: null, started_at: null, finished_at: null, state: 'created', queue: 'builds.linux', allow_failure: false }
|
||||
{ id: '8', repository_id: 1, repository_slug: 'travis-ci/travis-core', build_id: 5, commit_id: 5, log_id: 8, number: '5.2', config: { rvm: 'rbx' }, duration: null, started_at: null, finished_at: null, state: 'created', queue: 'builds.linux', allow_failure: false }
|
||||
]
|
||||
|
||||
artifacts = [
|
||||
|
@ -139,6 +141,16 @@ $.mockjax
|
|||
responseText:
|
||||
jobs: $.select(jobs, (job) -> job.state == 'created')
|
||||
|
||||
$.mockjax
|
||||
url: '/builds*'
|
||||
responseTime: responseTime
|
||||
response: (settings) ->
|
||||
if match = settings.url.match('/builds\\?(ids.*)')
|
||||
ids = match[1].split(new RegExp('&?ids\\[\\]=')).filter (str) -> str != ''
|
||||
this.responseText = { builds: $.select(builds, (build) -> ids.contains(build.id) ) }
|
||||
else
|
||||
throw "can't handle mocked request"
|
||||
|
||||
for data in branches
|
||||
$.mockjax
|
||||
url: '/branches'
|
||||
|
|
|
@ -1,46 +1,57 @@
|
|||
store = null
|
||||
record = null
|
||||
|
||||
describe 'Travis.Build', ->
|
||||
beforeEach ->
|
||||
store = Travis.Store.create()
|
||||
module "Travis.Build",
|
||||
setup: ->
|
||||
teardown: ->
|
||||
Travis.Build.resetData()
|
||||
Travis.Job.resetData()
|
||||
|
||||
afterEach ->
|
||||
store.destroy()
|
||||
test 'it does not load record on duration, finishedAt and result if job is not in finished state', ->
|
||||
Travis.Build.load [{ id: 1, state: 'started' }]
|
||||
|
||||
describe 'incomplete attributes', ->
|
||||
beforeEach ->
|
||||
store.loadIncomplete Travis.Build, { id: 1, state: 'started' }
|
||||
record = store.find Travis.Build, 1
|
||||
Ember.run ->
|
||||
record = Travis.Build.find 1
|
||||
|
||||
it 'does not load record on duration, finishedAt and result if job is not in finished state', ->
|
||||
record.get('_duration')
|
||||
record.get('finishedAt')
|
||||
record.get('result')
|
||||
record.loadTheRest = ->
|
||||
ok(false, 'loadTheRest should not be called')
|
||||
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeTruthy()
|
||||
record.get('_duration')
|
||||
record.get('finishedAt')
|
||||
record.get('result')
|
||||
|
||||
it 'loads the rest of the record if it\'s in finished state', ->
|
||||
store.loadIncomplete Travis.Build, { id: 1, state: 'passed' }
|
||||
record = store.find Travis.Build, 1
|
||||
record.get('finishedAt')
|
||||
wait().then ->
|
||||
ok(true, 'loadTheRest was not called')
|
||||
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeFalsy()
|
||||
test 'it loads record on duration, finishedAt and result if job is in finished state', ->
|
||||
expect(1)
|
||||
|
||||
describe 'configKeys', ->
|
||||
it 'takes into account all the jobs when getting config keys', ->
|
||||
buildConfig = { rvm: ['1.9.3', '2.0.0'] }
|
||||
store.load Travis.Build, { id: '1', job_ids: ['1', '2', '3'], config: buildConfig }, { id: '1' }
|
||||
Travis.Build.load [{ id: 1, state: 'passed' }]
|
||||
|
||||
store.load Travis.Job, { id: '1', config: { rvm: '1.9.3', env: 'FOO=foo' } }, { id: '1' }
|
||||
store.load Travis.Job, { id: '2', config: { rvm: '2.0.0', gemfile: 'Gemfile.1' } }, { id: '2' }
|
||||
store.load Travis.Job, { id: '3', config: { rvm: '1.9.3', jdk: 'OpenJDK' } }, { id: '3' }
|
||||
Ember.run ->
|
||||
record = Travis.Build.find 1
|
||||
|
||||
build = store.find(Travis.Build, '1')
|
||||
record.loadTheRest = ->
|
||||
ok(true, 'loadTheRest should be called')
|
||||
|
||||
expect( build.get('rawConfigKeys') ).toEqual( ['rvm', 'env', 'gemfile', 'jdk' ] )
|
||||
expect( build.get('configKeys') ).toEqual( [ 'Job', 'Duration', 'Finished', 'Rvm', 'Env', 'Gemfile', 'Jdk' ] )
|
||||
record.get('finishedAt')
|
||||
|
||||
wait()
|
||||
|
||||
test 'it takes into account all the jobs when getting config keys', ->
|
||||
buildConfig = { rvm: ['1.9.3', '2.0.0'] }
|
||||
Travis.Build.load [{ id: '1', job_ids: ['1', '2', '3'], config: buildConfig }]
|
||||
|
||||
Travis.Job.load [{ id: '1', config: { rvm: '1.9.3', env: 'FOO=foo' } }]
|
||||
Travis.Job.load [{ id: '2', config: { rvm: '2.0.0', gemfile: 'Gemfile.1' } }]
|
||||
Travis.Job.load [{ id: '3', config: { rvm: '1.9.3', jdk: 'OpenJDK' } }]
|
||||
|
||||
build = null
|
||||
rawConfigKeys = null
|
||||
configKeys = null
|
||||
Ember.run ->
|
||||
build = Travis.Build.find '1'
|
||||
rawConfigKeys = build.get('rawConfigKeys')
|
||||
configKeys = build.get('configKeys')
|
||||
|
||||
deepEqual(rawConfigKeys, ['rvm', 'env', 'gemfile', 'jdk' ])
|
||||
deepEqual(configKeys, [ 'Job', 'Duration', 'Finished', 'Rvm', 'Env', 'Gemfile', 'Jdk' ])
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
createChunk = (number, content, options) ->
|
||||
Em.Object.create(number: number, content: content, final: options?.final)
|
||||
|
||||
describe 'Travis.ChunkBuffer', ->
|
||||
it 'waits for parts to be in order before revealing them', ->
|
||||
buffer = Travis.ChunkBuffer.create(content: [])
|
||||
|
||||
buffer.pushObject createChunk(3, "baz")
|
||||
buffer.pushObject createChunk(2, "bar")
|
||||
|
||||
expect(buffer.get('length')).toEqual(0)
|
||||
|
||||
buffer.pushObject createChunk(1, "foo")
|
||||
|
||||
expect(buffer.get('length')).toEqual(3)
|
||||
|
||||
expect(buffer.toArray()).toEqual(['foo', 'bar', 'baz'])
|
||||
|
||||
it 'ignores a part if it fails to be delivered within timeout', ->
|
||||
buffer = Travis.ChunkBuffer.create(content: [], timeout: 20, checkTimeoutFrequency: 5)
|
||||
|
||||
buffer.pushObject createChunk(3, "baz")
|
||||
|
||||
expect(buffer.get('length')).toEqual(0)
|
||||
|
||||
buffer.pushObject createChunk(1, "foo")
|
||||
|
||||
expect(buffer.get('length')).toEqual(1)
|
||||
|
||||
waits 100
|
||||
runs ->
|
||||
expect(buffer.get('length')).toEqual(2)
|
||||
expect(buffer.toArray()).toEqual(['foo', 'baz'])
|
||||
|
||||
buffer.destroy()
|
||||
|
||||
it 'works correctly when parts are passed as content', ->
|
||||
content = [createChunk(2, 'bar')]
|
||||
|
||||
buffer = Travis.ChunkBuffer.create(content: content)
|
||||
|
||||
expect(buffer.get('length')).toEqual(0)
|
||||
|
||||
buffer.pushObject createChunk(1, "foo")
|
||||
|
||||
expect(buffer.get('length')).toEqual(2)
|
||||
expect(buffer.toArray()).toEqual(['foo', 'bar'])
|
||||
|
||||
it 'works correctly when parts duplicated', ->
|
||||
buffer = Travis.ChunkBuffer.create(content: [])
|
||||
|
||||
buffer.pushObject createChunk(1, "foo")
|
||||
buffer.pushObject createChunk(2, "bar")
|
||||
buffer.pushObject createChunk(3, "baz")
|
||||
|
||||
buffer.pushObject createChunk(2, "bar")
|
||||
buffer.pushObject createChunk(3, "baz")
|
||||
buffer.pushObject createChunk(4, "qux")
|
||||
|
||||
expect(buffer.get('length')).toEqual(4)
|
||||
expect(buffer.toArray()).toEqual(['foo', 'bar', 'baz', 'qux'])
|
||||
|
||||
it 'fires array observers properly', ->
|
||||
changes = []
|
||||
buffer = Travis.ChunkBuffer.create(content: [])
|
||||
|
||||
observer = Em.Object.extend(
|
||||
init: ->
|
||||
@_super.apply this, arguments
|
||||
|
||||
@get('content').addArrayObserver this,
|
||||
willChange: 'arrayWillChange',
|
||||
didChange: 'arrayDidChange'
|
||||
|
||||
arrayWillChange: (->)
|
||||
arrayDidChange: (array, index, removedCount, addedCount) ->
|
||||
changes.pushObject([index, addedCount])
|
||||
).create(content: buffer)
|
||||
|
||||
buffer.pushObject createChunk(2, "baz")
|
||||
|
||||
expect(buffer.get('length')).toEqual(0)
|
||||
expect(changes.length).toEqual(0)
|
||||
|
||||
buffer.pushObject createChunk(1, "foo")
|
||||
|
||||
expect(buffer.get('length')).toEqual(2)
|
||||
expect(changes.length).toEqual(1)
|
||||
expect(changes[0]).toEqual([0, 2])
|
||||
|
||||
it 'sets next to start if start is given at init', ->
|
||||
buffer = Travis.ChunkBuffer.create(content: [], start: 5)
|
||||
expect(buffer.get('next')).toEqual(5)
|
||||
|
||||
it 'runs finalize after getting final element', ->
|
||||
finalizeRuns = 0
|
||||
buffer = Travis.ChunkBuffer.extend({
|
||||
finalize: ->
|
||||
@_super.apply this, arguments
|
||||
finalizeRuns += 1
|
||||
}).create(content: [])
|
||||
|
||||
buffer.pushObject createChunk(1, "foo")
|
||||
buffer.pushObject createChunk(2, "bar")
|
||||
buffer.pushObject createChunk(3, "baz")
|
||||
|
||||
expect(finalizeRuns).toEqual(0)
|
||||
|
||||
buffer.pushObject createChunk(4, "qux", final: true)
|
||||
|
||||
expect(buffer.get('length')).toEqual(4)
|
||||
|
||||
expect(finalizeRuns).toEqual(1)
|
|
@ -1,188 +1,83 @@
|
|||
record = null
|
||||
store = null
|
||||
adapterClass = null
|
||||
fullPostHash = null
|
||||
Post = null
|
||||
Author = null
|
||||
|
||||
describe 'Travis.Model - incomplete', ->
|
||||
beforeEach ->
|
||||
$.mockjax
|
||||
url: '/foos/1'
|
||||
responseTime: 1
|
||||
responseText: { foo: { id: 1, name: 'foo', description: 'bar' } }
|
||||
module "Travis.Model - incomplete",
|
||||
setup: ->
|
||||
fullPostHash = {
|
||||
id: '1',
|
||||
title: 'foo',
|
||||
published_at: 'today',
|
||||
|
||||
Travis.Foo = Travis.Model.extend
|
||||
name: DS.attr('string')
|
||||
description: DS.attr('string')
|
||||
lastName: DS.attr('string')
|
||||
author_id: '1'
|
||||
}
|
||||
|
||||
bar: DS.belongsTo('Travis.Bar')
|
||||
niceBar: DS.belongsTo('Travis.Bar')
|
||||
veryNiceBar: DS.belongsTo('Travis.Bar')
|
||||
Author = Travis.Model.extend()
|
||||
|
||||
Travis.Foo.toString = -> 'Travis.Foo'
|
||||
Post = Travis.Model.extend(
|
||||
title: Ember.attr('string'),
|
||||
publishedAt: Ember.attr('string', key: 'published_at'),
|
||||
|
||||
Travis.Bar = Travis.Model.extend
|
||||
name: DS.attr('string')
|
||||
foos: DS.hasMany('Travis.Foo')
|
||||
author: Ember.belongsTo(Author, { key: 'author_id' })
|
||||
)
|
||||
|
||||
Travis.Bar.toString = -> 'Travis.Bar'
|
||||
Post.adapter = Ember.FixtureAdapter.create()
|
||||
|
||||
adapterClass = Travis.RestAdapter.extend()
|
||||
adapterClass.map 'Travis.Foo',
|
||||
veryNiceBar: { key: 'very_nice_bar_indeed_id' }
|
||||
niceBar: { key: 'nice_bar_id' }
|
||||
test "record is marked as incomplete if attributes are missing when loading a record", ->
|
||||
Post.load([{ id: '1', title: 'foo' }])
|
||||
|
||||
store = Travis.Store.create
|
||||
adapter: adapterClass.create()
|
||||
record = Post.find('1')
|
||||
ok(record.get('incomplete'), 'record should be incomplete')
|
||||
equal(record.get('title'), 'foo', 'attributes should be accessible')
|
||||
|
||||
afterEach ->
|
||||
delete Travis.Foo
|
||||
delete Travis.Bar
|
||||
store.destroy()
|
||||
test "record is marked as complete if missing attributes are loaded", ->
|
||||
Post.load([{ id: '1', title: 'foo' }])
|
||||
|
||||
it 'allows to merge many times', ->
|
||||
store.load(Travis.Bar, { id: '1', foo_ids: ['1', '2'] }, { id: '1' })
|
||||
store.load(Travis.Foo, { id: '1', bar_id: '1' }, { id: '1' })
|
||||
store.load(Travis.Foo, { id: '2', bar_id: '1' }, { id: '2' })
|
||||
record = Post.find('1')
|
||||
ok(record.get('incomplete'), 'record should be complete')
|
||||
equal(record.get('title'), 'foo', 'attributes should be accessible')
|
||||
|
||||
record = store.find(Travis.Bar, 1)
|
||||
store.find(Travis.Foo, 1)
|
||||
store.find(Travis.Foo, 2)
|
||||
record.load('1', fullPostHash)
|
||||
|
||||
record.get('foos')
|
||||
store.loadIncomplete(Travis.Bar, id: 1, name: 'foo')
|
||||
store.loadIncomplete(Travis.Bar, id: 1, name: 'bar')
|
||||
ok(!record.get('incomplete'), 'record should be complete')
|
||||
|
||||
expect( record.get('foos.length') ).toEqual(2)
|
||||
expect( record.get('name') ).toEqual('bar')
|
||||
test "record is marked as incomplete if belongsTo key is missing", ->
|
||||
delete(fullPostHash.author_id)
|
||||
Post.load([fullPostHash])
|
||||
|
||||
describe 'with incomplete record with loaded associations', ->
|
||||
beforeEach ->
|
||||
attrs = {
|
||||
id: 1
|
||||
bar_id: 2
|
||||
nice_bar_id: 3
|
||||
very_nice_bar_indeed_id: 4
|
||||
}
|
||||
store.loadIncomplete(Travis.Foo, attrs)
|
||||
record = store.find Travis.Foo, 1
|
||||
store.load(Travis.Bar, id: 2)
|
||||
store.load(Travis.Bar, id: 3)
|
||||
store.load(Travis.Bar, id: 4)
|
||||
record = Post.find('1')
|
||||
ok(record.get('incomplete'), 'record should be incomplete')
|
||||
|
||||
it 'does not load record on association access', ->
|
||||
expect( record.get('bar.id') ).toEqual '2'
|
||||
expect( record.get('niceBar.id') ).toEqual '3'
|
||||
expect( record.get('veryNiceBar.id') ).toEqual '4'
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeTruthy()
|
||||
test "proeperty can be loaded as null, which means that the property is still loaded", ->
|
||||
fullPostHash.author_id = null
|
||||
fullPostHash.title = null
|
||||
|
||||
describe 'with incomplete record without loaded associations', ->
|
||||
beforeEach ->
|
||||
attrs = {
|
||||
id: 1
|
||||
}
|
||||
store.loadIncomplete(Travis.Foo, attrs)
|
||||
record = store.find Travis.Foo, 1
|
||||
Post.load([fullPostHash])
|
||||
|
||||
it 'loads record based on regular association key', ->
|
||||
record.get('bar')
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeFalsy()
|
||||
record = Post.find('1')
|
||||
ok(!record.get('incomplete'), 'record should be complete')
|
||||
equal(record.get('title'), null, 'title should be null')
|
||||
|
||||
it 'loads record based on camel case association key', ->
|
||||
record.get('niceBar')
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeFalsy()
|
||||
test "when accessing missing property, record is loaded", ->
|
||||
Post.FIXTURES = [fullPostHash]
|
||||
Post.load([{ id: '1' }])
|
||||
|
||||
it 'loads record based on ssociation with explicit key', ->
|
||||
record.get('veryNiceBar')
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeFalsy()
|
||||
record = null
|
||||
Ember.run -> record = Post.find('1')
|
||||
|
||||
describe 'with incomplete record', ->
|
||||
beforeEach ->
|
||||
attrs = {
|
||||
id: 1
|
||||
name: 'foo'
|
||||
last_name: 'foobar'
|
||||
}
|
||||
store.loadIncomplete(Travis.Foo, attrs)
|
||||
record = store.find Travis.Foo, 1
|
||||
ok(record.get('incomplete'), 'record should be incomplete')
|
||||
|
||||
it 'shows if attribute is loaded', ->
|
||||
expect( record.isAttributeLoaded('name') ).toBeTruthy()
|
||||
expect( record.isAttributeLoaded('description') ).toBeFalsy()
|
||||
publishedAt = null
|
||||
Ember.run -> publishedAt = record.get('publishedAt')
|
||||
|
||||
it 'does not trigger a request when getting known attribute', ->
|
||||
expect( record.get('name') ).toEqual 'foo'
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeTruthy()
|
||||
ok(!publishedAt, 'publishedAt should be missing')
|
||||
|
||||
it 'loads missing data if getPath is used', ->
|
||||
other = Em.Object.create(record: record)
|
||||
expect( other.get('record.description') ).toBeNull()
|
||||
stop()
|
||||
setTimeout( ->
|
||||
start()
|
||||
|
||||
waits 50
|
||||
runs ->
|
||||
expect( other.get('record.description') ).toEqual 'bar'
|
||||
expect( record.get('isComplete') ).toBeTruthy()
|
||||
Ember.run -> publishedAt = record.get('publishedAt')
|
||||
equal(publishedAt, 'today', 'publishedAt should be loaded')
|
||||
ok(!record.get('incomplete'), 'record should be complete')
|
||||
, 50)
|
||||
|
||||
it 'loads missing data on try to get it', ->
|
||||
expect( record.get('name') ).toEqual 'foo'
|
||||
expect( record.get('description') ).toBeNull()
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('description') ).toEqual 'bar'
|
||||
expect( record.get('isComplete') ).toBeTruthy()
|
||||
|
||||
it 'does not set incomplete on the record twice', ->
|
||||
record.get('description')
|
||||
waits 50
|
||||
runs ->
|
||||
store.loadIncomplete(Travis.Foo, id: 1)
|
||||
expect( record.get('incomplete') ).toBeFalsy()
|
||||
|
||||
it 'does not load data on non attribute', ->
|
||||
record.get('foobarbaz')
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeTruthy()
|
||||
|
||||
it 'works with camel case values', ->
|
||||
expect( record.get('lastName') ).toEqual 'foobar'
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeTruthy()
|
||||
|
||||
it 'adds takes into account additional data loaded as incomplete', ->
|
||||
store.loadIncomplete(Travis.Foo, { id: 1, description: 'baz' })
|
||||
record = store.find Travis.Foo, 1
|
||||
expect( record.get('description') ).toEqual 'baz'
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeTruthy()
|
||||
|
||||
describe 'with complete record', ->
|
||||
beforeEach ->
|
||||
id = '5'
|
||||
attrs = {
|
||||
id: id
|
||||
name: 'foo'
|
||||
}
|
||||
|
||||
store.load(Travis.Foo, attrs, { id: attrs.id })
|
||||
record = store.find(Travis.Foo, id)
|
||||
|
||||
it 'is marked as completed', ->
|
||||
expect( record.get('incomplete') ).toBeFalsy()
|
||||
|
||||
it 'allows to get regular attribute', ->
|
||||
expect( record.get('name') ).toEqual 'foo'
|
||||
|
||||
it 'allows to check attribute state', ->
|
||||
expect( record.isAttributeLoaded('name') ).toBeFalsy()
|
||||
|
|
1
assets/scripts/spec/unit/incomplete_spec.js
Normal file
1
assets/scripts/spec/unit/incomplete_spec.js
Normal file
|
@ -0,0 +1 @@
|
|||
|
|
@ -1,86 +1,113 @@
|
|||
store = null
|
||||
record = null
|
||||
|
||||
describe 'Travis.Job', ->
|
||||
beforeEach ->
|
||||
store = Travis.Store.create()
|
||||
module "Travis.Job",
|
||||
setup: ->
|
||||
teardown: ->
|
||||
Travis.Job.resetData()
|
||||
Travis.Build.resetData()
|
||||
|
||||
afterEach ->
|
||||
store.destroy()
|
||||
test 'configKeys takes into account the keys of other jobs', ->
|
||||
buildConfig = { rvm: ['1.9.3', '2.0.0'] }
|
||||
Travis.Build.load [{ id: '1', job_ids: ['1', '2', '3'], config: buildConfig }]
|
||||
|
||||
describe 'configKeys', ->
|
||||
it 'takes into account the keys of other jobs', ->
|
||||
buildConfig = { rvm: ['1.9.3', '2.0.0'] }
|
||||
store.load Travis.Build, { id: '1', job_ids: ['1', '2', '3'], config: buildConfig }, { id: '1' }
|
||||
Travis.Job.load [{ id: '1', config: { rvm: '1.9.3', env: 'FOO=foo' }, build_id: '1' }]
|
||||
Travis.Job.load [{ id: '2', config: { rvm: '2.0.0', gemfile: 'Gemfile.1' }, build_id: '1' }]
|
||||
Travis.Job.load [{ id: '3', config: { rvm: '1.9.3', jdk: 'OpenJDK' }, build_id: '1' }]
|
||||
|
||||
store.load Travis.Job, { id: '1', config: { rvm: '1.9.3', env: 'FOO=foo' }, build_id: '1' }, { id: '1' }
|
||||
store.load Travis.Job, { id: '2', config: { rvm: '2.0.0', gemfile: 'Gemfile.1' }, build_id: '1' }, { id: '2' }
|
||||
store.load Travis.Job, { id: '3', config: { rvm: '1.9.3', jdk: 'OpenJDK' }, build_id: '1' }, { id: '3' }
|
||||
configValues1 = null
|
||||
configValues2 = null
|
||||
configValues3 = null
|
||||
job1 = null
|
||||
job2 = null
|
||||
job3 = null
|
||||
|
||||
job1 = store.find(Travis.Job, '1')
|
||||
job2 = store.find(Travis.Job, '2')
|
||||
job3 = store.find(Travis.Job, '3')
|
||||
Ember.run ->
|
||||
job1 = Travis.Job.find('1')
|
||||
job2 = Travis.Job.find('2')
|
||||
job3 = Travis.Job.find('3')
|
||||
|
||||
expect( job1.get('configValues') ).toEqual( [ '1.9.3', 'FOO=foo', undefined, undefined ] )
|
||||
expect( job2.get('configValues') ).toEqual( [ '2.0.0', undefined, 'Gemfile.1', undefined ] )
|
||||
expect( job3.get('configValues') ).toEqual( [ '1.9.3', undefined, undefined, 'OpenJDK' ] )
|
||||
wait().then ->
|
||||
Ember.run ->
|
||||
configValues1 = job1.get('configValues')
|
||||
configValues2 = job2.get('configValues')
|
||||
configValues3 = job3.get('configValues')
|
||||
|
||||
describe 'incomplete attributes', ->
|
||||
beforeEach ->
|
||||
store.loadIncomplete Travis.Job, { id: 1, state: 'started' }
|
||||
record = store.find Travis.Job, 1
|
||||
deepEqual( configValues1, [ '1.9.3', 'FOO=foo', undefined, undefined ] )
|
||||
deepEqual( configValues2, [ '2.0.0', undefined, 'Gemfile.1', undefined ] )
|
||||
deepEqual( configValues3, [ '1.9.3', undefined, undefined, 'OpenJDK' ] )
|
||||
|
||||
it 'does not load record on duration, finishedAt and result if job is not in finished state', ->
|
||||
record.get('_duration')
|
||||
record.get('finishedAt')
|
||||
record.get('result')
|
||||
test 'it does not load record on duration, finishedAt and result if job is not in finished state', ->
|
||||
Travis.Job.load [{ id: 1, state: 'started' }]
|
||||
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeTruthy()
|
||||
Ember.run ->
|
||||
record = Travis.Job.find 1
|
||||
|
||||
it 'loads the rest of the record if it\'s in finished state', ->
|
||||
store.loadIncomplete Travis.Job, { id: 1, state: 'passed' }
|
||||
record = store.find Travis.Job, 1
|
||||
record.get('finishedAt')
|
||||
record.loadTheRest = ->
|
||||
ok(false, 'loadTheRest should not be called')
|
||||
|
||||
waits 50
|
||||
runs ->
|
||||
expect( record.get('incomplete') ).toBeFalsy()
|
||||
record.get('_duration')
|
||||
record.get('finishedAt')
|
||||
record.get('result')
|
||||
|
||||
wait().then ->
|
||||
ok(true, 'loadTheRest was not called')
|
||||
|
||||
describe 'with different number of config keys in sibling jobs', ->
|
||||
beforeEach ->
|
||||
buildAttrs =
|
||||
id: 1
|
||||
job_ids: [1, 2]
|
||||
config:
|
||||
jdk: ['oraclejdk7']
|
||||
rvm: ['jruby-head']
|
||||
test 'it loads record on duration, finishedAt and result if job is in finished state', ->
|
||||
expect(1)
|
||||
|
||||
store.load Travis.Build, 1, buildAttrs
|
||||
Travis.Job.load [{ id: 1, state: 'passed' }]
|
||||
|
||||
jobAttrs =
|
||||
id: 1
|
||||
build_id: 1
|
||||
config:
|
||||
jdk: 'oraclejdk7'
|
||||
rvm: 'jruby-head'
|
||||
Ember.run ->
|
||||
record = Travis.Job.find 1
|
||||
|
||||
store.load Travis.Job, 1, jobAttrs
|
||||
record.loadTheRest = ->
|
||||
ok(true, 'loadTheRest should be called')
|
||||
|
||||
jobAttrs =
|
||||
id: 2
|
||||
build_id: 1
|
||||
config:
|
||||
jdk: null
|
||||
rvm: 'jruby-head'
|
||||
record.get('finishedAt')
|
||||
|
||||
store.load Travis.Job, 2, jobAttrs
|
||||
wait()
|
||||
|
||||
it 'returns config values for all keys available on build', ->
|
||||
job1 = store.find Travis.Job, 1
|
||||
job2 = store.find Travis.Job, 2
|
||||
test 'returns config values for all keys available on build with different number of config keys in sibling jobs', ->
|
||||
buildAttrs =
|
||||
id: 1
|
||||
job_ids: [1, 2]
|
||||
config:
|
||||
jdk: ['oraclejdk7']
|
||||
rvm: ['jruby-head']
|
||||
|
||||
expect( job1.get('configValues') ).toEqual ['oraclejdk7', 'jruby-head']
|
||||
expect( job2.get('configValues') ).toEqual [undefined, 'jruby-head']
|
||||
Travis.Build.load [buildAttrs]
|
||||
|
||||
jobAttrs =
|
||||
id: 1
|
||||
build_id: 1
|
||||
config:
|
||||
jdk: 'oraclejdk7'
|
||||
rvm: 'jruby-head'
|
||||
|
||||
Travis.Job.load [jobAttrs]
|
||||
|
||||
jobAttrs =
|
||||
id: 2
|
||||
build_id: 1
|
||||
config:
|
||||
jdk: null
|
||||
rvm: 'jruby-head'
|
||||
|
||||
Travis.Job.load [jobAttrs]
|
||||
|
||||
configValues1 = null
|
||||
configValues2 = null
|
||||
job1 = null
|
||||
job2 = null
|
||||
|
||||
Ember.run ->
|
||||
job1 = Travis.Job.find(1)
|
||||
job2 = Travis.Job.find(2)
|
||||
|
||||
wait().then ->
|
||||
Ember.run ->
|
||||
configValues1 = job1.get('configValues')
|
||||
configValues2 = job2.get('configValues')
|
||||
|
||||
deepEqual( configValues1, ['oraclejdk7', 'jruby-head'] )
|
||||
deepEqual( configValues2, [undefined, 'jruby-head'] )
|
||||
|
|
|
@ -1,46 +1,47 @@
|
|||
describe 'Travis.LimitedArray', ->
|
||||
it 'limits given content', ->
|
||||
content = [1, 2, 3]
|
||||
array = Travis.LimitedArray.create content: content, limit: 2
|
||||
expect( array.get('length') ).toEqual 2
|
||||
expect( array.toArray() ).toEqual [1, 2]
|
||||
module 'Travis.LimitedArray'
|
||||
|
||||
it 'inserts content at the right place when unshifting', ->
|
||||
content = [1, 2, 3]
|
||||
array = Travis.LimitedArray.create content: content, limit: 2
|
||||
content.unshiftObject 0
|
||||
expect( array.get('length') ).toEqual 2
|
||||
expect( array.toArray() ).toEqual [0, 1]
|
||||
test 'limits given content', ->
|
||||
content = [1, 2, 3]
|
||||
array = Travis.LimitedArray.create content: content, limit: 2
|
||||
equal( array.get('length'), 2 )
|
||||
deepEqual( array.toArray(), [1, 2] )
|
||||
|
||||
it 'does not insert content when it\'s inserted not in the limited range', ->
|
||||
content = [1, 2, 3]
|
||||
array = Travis.LimitedArray.create content: content, limit: 2
|
||||
content.pushObject 0
|
||||
expect( array.get('length') ).toEqual 2
|
||||
expect( array.toArray() ).toEqual [1, 2]
|
||||
test 'inserts content at the right place when unshifting', ->
|
||||
content = [1, 2, 3]
|
||||
array = Travis.LimitedArray.create content: content, limit: 2
|
||||
content.unshiftObject 0
|
||||
equal( array.get('length'), 2 )
|
||||
deepEqual( array.toArray(), [0, 1] )
|
||||
|
||||
it 'properly removes items', ->
|
||||
content = [1, 2, 3]
|
||||
array = Travis.LimitedArray.create content: content, limit: 2
|
||||
content.shiftObject()
|
||||
test 'does not insert content when it\'s inserted not in the limited range', ->
|
||||
content = [1, 2, 3]
|
||||
array = Travis.LimitedArray.create content: content, limit: 2
|
||||
content.pushObject 0
|
||||
equal( array.get('length'), 2 )
|
||||
deepEqual( array.toArray(), [1, 2] )
|
||||
|
||||
expect( array.get('length') ).toEqual 2
|
||||
expect( array.toArray() ).toEqual [2, 3]
|
||||
test 'properly removes items', ->
|
||||
content = [1, 2, 3]
|
||||
array = Travis.LimitedArray.create content: content, limit: 2
|
||||
content.shiftObject()
|
||||
|
||||
content.shiftObject()
|
||||
equal( array.get('length'), 2 )
|
||||
deepEqual( array.toArray(), [2, 3] )
|
||||
|
||||
expect( array.get('length') ).toEqual 1
|
||||
expect( array.toArray() ).toEqual [3]
|
||||
content.shiftObject()
|
||||
|
||||
content.shiftObject()
|
||||
equal( array.get('length'), 1 )
|
||||
deepEqual( array.toArray(), [3] )
|
||||
|
||||
expect( array.get('length') ).toEqual 0
|
||||
content.shiftObject()
|
||||
|
||||
it 'allows to expand array to show all items', ->
|
||||
content = [1, 2, 3]
|
||||
array = Travis.LimitedArray.create content: content, limit: 2
|
||||
equal( array.get('length'), 0)
|
||||
|
||||
array.showAll()
|
||||
test 'allows to expand array to show all items', ->
|
||||
content = [1, 2, 3]
|
||||
array = Travis.LimitedArray.create content: content, limit: 2
|
||||
|
||||
expect( array.get('length') ).toEqual 3
|
||||
expect( array.toArray() ).toEqual [1, 2, 3]
|
||||
array.showAll()
|
||||
|
||||
equal( array.get('length'), 3)
|
||||
deepEqual( array.toArray(), [1, 2, 3])
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
record = null
|
||||
store = null
|
||||
|
||||
describe 'Travis.Model - merge', ->
|
||||
beforeEach ->
|
||||
Travis.Foo = Travis.Model.extend
|
||||
login: DS.attr('string')
|
||||
firstName: DS.attr('string')
|
||||
email: DS.attr('string')
|
||||
|
||||
bar: DS.belongsTo('Travis.Bar')
|
||||
|
||||
Travis.Bar = Travis.Model.extend
|
||||
foos: DS.hasMany('Travis.Foo')
|
||||
|
||||
store = Travis.Store.create()
|
||||
|
||||
afterEach ->
|
||||
delete Travis.Foo
|
||||
delete Travis.Bar
|
||||
store.destroy()
|
||||
|
||||
it 'updates the attributes of materialized record', ->
|
||||
data = { id: '1', firstName: 'Piotr', email: 'drogus@example.org' }
|
||||
store.load(Travis.Foo, { id: '1' }, data)
|
||||
record = store.find(Travis.Foo, '1')
|
||||
|
||||
changes = 0
|
||||
|
||||
observer = ->
|
||||
changes += 1
|
||||
record.addObserver 'firstName', observer
|
||||
|
||||
Ember.run ->
|
||||
store.merge(Travis.Foo, { id: '1', first_name: 'Peter', login: 'drogus' })
|
||||
|
||||
record.removeObserver 'firstName', observer
|
||||
|
||||
expect(changes > 0).toBeTruthy()
|
||||
expect(record.get('firstName')).toEqual('Peter')
|
||||
expect(record.get('login')).toEqual('drogus')
|
||||
expect(record.get('email')).toEqual('drogus@example.org')
|
||||
|
||||
it 'updates belongsTo relationship of materialized record', ->
|
||||
data = { id: '1', login: 'drogus', bar_id: '1' }
|
||||
store.load(Travis.Foo, data, { id: '1' })
|
||||
store.load(Travis.Bar, { id: '1' }, { id: '1' })
|
||||
store.load(Travis.Bar, { id: '2' }, { id: '2' })
|
||||
record = store.find(Travis.Foo, '1')
|
||||
|
||||
changed = false
|
||||
|
||||
observer = ->
|
||||
changed = true
|
||||
record.addObserver 'bar', observer
|
||||
|
||||
Ember.run ->
|
||||
store.merge(Travis.Foo, { id: '1', bar_id: '2' })
|
||||
|
||||
record.removeObserver 'bar', observer
|
||||
|
||||
bar = store.find(Travis.Bar, '2')
|
||||
|
||||
expect(changed).toEqual(true)
|
||||
expect(record.get('bar')).toEqual(bar)
|
||||
|
||||
it 'updates hasMany relationship of materialized record', ->
|
||||
data = { id: '1', foo_ids: [1] }
|
||||
store.load(Travis.Bar, data, { id: '1' })
|
||||
store.load(Travis.Foo, { id: '1' }, { id: '1' })
|
||||
store.load(Travis.Foo, { id: '2' }, { id: '2' })
|
||||
|
||||
record = store.find(Travis.Bar, '1')
|
||||
|
||||
changed = false
|
||||
|
||||
observer = ->
|
||||
changed = true
|
||||
record.addObserver 'foos.length', observer
|
||||
|
||||
Ember.run ->
|
||||
store.merge(Travis.Bar, { id: '1', foo_ids: [1, 2] })
|
||||
|
||||
record.removeObserver 'foos.length', observer
|
||||
|
||||
expect(changed).toEqual(true)
|
||||
expect(record.get('foos.length')).toEqual(2)
|
||||
expect(record.get('foos').mapProperty('id')).toEqual(['1', '2'])
|
||||
|
||||
it 'loads given data if it\'s not in the store yet', ->
|
||||
store.merge(Travis.Foo, { id: '1', login: 'drogus' })
|
||||
|
||||
record = store.find(Travis.Foo, 1)
|
||||
|
||||
expect(record.get('login')).toEqual('drogus')
|
||||
expect(record.get('email')).toEqual(null)
|
||||
|
||||
it 'merges data if it\'s just loaded into store', ->
|
||||
store.load(Travis.Foo, { id: '1', login: 'drogus', email: 'drogus@example.org' }, { id: '1' })
|
||||
store.merge(Travis.Foo, { id: '1', login: 'svenfuchs' })
|
||||
|
||||
record = store.find(Travis.Foo, 1)
|
||||
|
||||
expect(record.get('login')).toEqual('svenfuchs')
|
||||
expect(record.get('email')).toEqual('drogus@example.org')
|
122
assets/scripts/spec/unit/model_spec.coffee
Normal file
122
assets/scripts/spec/unit/model_spec.coffee
Normal file
|
@ -0,0 +1,122 @@
|
|||
fullPostHash = null
|
||||
Post = null
|
||||
Author = null
|
||||
Comment = null
|
||||
|
||||
module "Travis.Model",
|
||||
setup: ->
|
||||
fullPostHash = {
|
||||
id: '1',
|
||||
title: 'foo',
|
||||
published_at: 'today',
|
||||
|
||||
author_id: '1',
|
||||
comment_ids: ['1', '2']
|
||||
}
|
||||
|
||||
Author = Travis.Model.extend(
|
||||
name: Ember.attr('string')
|
||||
)
|
||||
Author.toString = -> return 'Author'
|
||||
|
||||
Comment = Travis.Model.extend(
|
||||
body: Ember.attr('string')
|
||||
)
|
||||
Comment.toString = -> return 'Comment'
|
||||
|
||||
Post = Travis.Model.extend(
|
||||
title: Ember.attr('string'),
|
||||
publishedAt: Ember.attr('string'),
|
||||
|
||||
author: Ember.belongsTo(Author, { key: 'author_id' }),
|
||||
comments: Ember.hasMany(Comment, { key: 'comment_ids' })
|
||||
)
|
||||
Post.toString = -> return 'Post'
|
||||
|
||||
Comment.adapter = Ember.FixtureAdapter.create()
|
||||
Author.adapter = Ember.FixtureAdapter.create()
|
||||
Post.adapter = Ember.FixtureAdapter.create()
|
||||
|
||||
Author.load([
|
||||
{ id: '1', name: 'drogus' }
|
||||
])
|
||||
Comment.load([
|
||||
{ id: '1', body: 'comment 1' },
|
||||
{ id: '2', body: 'comment 2' }
|
||||
])
|
||||
test "new data can be merged into the record", ->
|
||||
delete fullPostHash.title
|
||||
delete fullPostHash.author_id
|
||||
delete fullPostHash.comment_ids
|
||||
post = Post.findFromCacheOrLoad(fullPostHash)
|
||||
|
||||
post.loadTheRest = (->)
|
||||
|
||||
equal(post.get('title'), null, 'title should be null')
|
||||
equal(post.get('comments.length'), 0, 'comments should be empty')
|
||||
equal(post.get('author'), null, 'author should be null')
|
||||
|
||||
Ember.run -> post.merge(title: 'teh title', comment_ids: ['1', '2'], author_id: '1')
|
||||
|
||||
author = null
|
||||
Ember.run -> author = Author.find('1').get('name')
|
||||
title = null
|
||||
Ember.run -> title = post.get('title')
|
||||
console.log('title', title)
|
||||
|
||||
equal(post.get('title'), 'teh title', 'title should be updated')
|
||||
equal(post.get('comments.length'), 2, 'comments should be updated and have length of 2')
|
||||
equal(post.get('comments.firstObject.body'), 'comment 1', 'comment should be loaded')
|
||||
equal(author, 'drogus', 'author should be loaded')
|
||||
equal(post.get('publishedAt'), 'today', 'existing attributes are not overwritten')
|
||||
|
||||
module "Travis.Model.loadOrMerge",
|
||||
setup: ->
|
||||
Post = Travis.Model.extend(
|
||||
title: Ember.attr('string')
|
||||
)
|
||||
Post.toString = -> return 'Post'
|
||||
|
||||
test "it doesn't update record if skipIfExists is passed and record is already in store", ->
|
||||
Post.load([{id: '1', title: 'foo'}])
|
||||
|
||||
post = Post.find('1')
|
||||
equal(post.get('title'), 'foo', 'precondition - title of the post should be set')
|
||||
|
||||
Ember.run ->
|
||||
Travis.loadOrMerge(Post, { id: '1', title: 'bar' }, { skipIfExists: true })
|
||||
|
||||
equal(post.get('title'), 'foo', 'title should stay unchanged')
|
||||
|
||||
test "it updates record if record is already in the store", ->
|
||||
Post.load([{id: '1', title: 'foo'}])
|
||||
|
||||
post = Post.find('1')
|
||||
equal(post.get('title'), 'foo', 'precondition - title of the post should be set')
|
||||
|
||||
Ember.run ->
|
||||
Travis.loadOrMerge(Post, { id: '1', title: 'bar' })
|
||||
|
||||
equal(post.get('title'), 'bar', 'title should be updated')
|
||||
|
||||
test "record is not instantiated by default", ->
|
||||
reference = null
|
||||
Ember.run ->
|
||||
reference = Travis.loadOrMerge(Post, { id: '1', title: 'bar' })
|
||||
|
||||
equal(reference.id, '1', 'reference should be created')
|
||||
ok(Ember.isNone(reference.record), 'record should not be created')
|
||||
|
||||
post = null
|
||||
Ember.run -> post = Post.find('1')
|
||||
equal(post.get('title'), 'bar', 'record should be loaded from cached data')
|
||||
equal(reference.record, post, 'record should be created')
|
||||
|
||||
test "data is merged to the existing data cache", ->
|
||||
Post.load([{id: '1', title: 'foo'}])
|
||||
|
||||
Ember.run ->
|
||||
Travis.loadOrMerge(Post, { id: '1', title: 'bar' })
|
||||
|
||||
post = Post.find('1')
|
||||
equal(post.get('title'), 'bar', 'title should be updated')
|
Loading…
Reference in New Issue
Block a user