Fix specs and add missing spec file

This commit is contained in:
Piotr Sarnacki 2012-10-16 12:14:45 +02:00
parent c05ce673bf
commit 96acd8e526
5 changed files with 73 additions and 19 deletions

View File

@ -92,6 +92,15 @@ describe 'events', ->
payload = payload =
job: job:
id: 15 id: 15
repository_id: 1
build_id: 1
commit_id: 1
log_id: 1
number: '1.4'
duration: 55
started_at: '2012-07-02T00:02:00Z'
finished_at: '2012-07-02T00:02:55Z'
config: { rvm: 'jruby' }
$.mockjax $.mockjax
url: '/jobs/15' url: '/jobs/15'
@ -105,12 +114,6 @@ describe 'events', ->
repository_id: 1 repository_id: 1
build_id: 1 build_id: 1
commit_id: 1 commit_id: 1
log_id: 1
number: '1.4'
duration: 55
started_at: '2012-07-02T00:02:00Z'
finished_at: '2012-07-02T00:02:55Z'
config: { rvm: 'jruby' }
waits(100) waits(100)
runs -> runs ->

View File

@ -22,7 +22,7 @@ minispade.require 'app'
runs -> runs ->
url = "/#{url}" if url && !url.match(/^\//) url = "/#{url}" if url && !url.match(/^\//)
Travis.app.router.route(url) Travis.app.router.route(url)
waits 100 waits 500
runs -> runs ->
foo = 'bar' foo = 'bar'

View File

@ -0,0 +1,48 @@
Travis.Foo = Travis.Model.extend
name: DS.attr('string')
description: DS.attr('string')
record = null
store = null
$.mockjax
url: '/foos/1'
responseTime: 10
responseText: { foo: { id: 1, name: 'foo', description: 'bar' } }
describe 'Travis.Model', ->
describe 'with incomplete record', ->
beforeEach ->
store = Travis.Store.create()
attrs = {
id: 1
name: 'foo'
}
record = store.loadIncomplete(Travis.Foo, attrs)
it 'shows if attribute is loaded', ->
expect( record.isAttributeLoaded('name') ).toBeTruthy()
expect( record.isAttributeLoaded('description') ).toBeFalsy()
it 'does not trigger a request when getting known attribute', ->
expect( record.get('name') ).toEqual 'foo'
waits 50
runs ->
expect( record.get('complete') ).toBeFalsy()
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('complete') ).toBeTruthy()
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()

View File

@ -8443,7 +8443,18 @@ return sinon;}.call(typeof window != 'undefined' && window || {}));
var payload; var payload;
payload = { payload = {
job: { job: {
id: 15 id: 15,
repository_id: 1,
build_id: 1,
commit_id: 1,
log_id: 1,
number: '1.4',
duration: 55,
started_at: '2012-07-02T00:02:00Z',
finished_at: '2012-07-02T00:02:55Z',
config: {
rvm: 'jruby'
}
} }
}; };
$.mockjax({ $.mockjax({
@ -8457,15 +8468,7 @@ return sinon;}.call(typeof window != 'undefined' && window || {}));
id: 15, id: 15,
repository_id: 1, repository_id: 1,
build_id: 1, build_id: 1,
commit_id: 1, commit_id: 1
log_id: 1,
number: '1.4',
duration: 55,
started_at: '2012-07-02T00:02:00Z',
finished_at: '2012-07-02T00:02:55Z',
config: {
rvm: 'jruby'
}
} }
}); });
}); });
@ -8847,7 +8850,7 @@ return sinon;}.call(typeof window != 'undefined' && window || {}));
url = "/" + url; url = "/" + url;
} }
Travis.app.router.route(url); Travis.app.router.route(url);
waits(100); waits(500);
return runs(function() { return runs(function() {
var foo; var foo;
return foo = 'bar'; return foo = 'bar';

View File

@ -1 +1 @@
e090359a 402ce94f