From 96acd8e526b7c33f3efcfab975e510dd93f172b7 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 16 Oct 2012 12:14:45 +0200 Subject: [PATCH] Fix specs and add missing spec file --- assets/scripts/spec/event_spec.coffee | 15 +++--- assets/scripts/spec/spec_helper.coffee | 2 +- .../scripts/spec/unit/incomplete_spec.coffee | 48 +++++++++++++++++++ public/scripts/specs.js | 25 +++++----- public/version | 2 +- 5 files changed, 73 insertions(+), 19 deletions(-) create mode 100644 assets/scripts/spec/unit/incomplete_spec.coffee diff --git a/assets/scripts/spec/event_spec.coffee b/assets/scripts/spec/event_spec.coffee index 8f8f0610..c6c3f9d9 100644 --- a/assets/scripts/spec/event_spec.coffee +++ b/assets/scripts/spec/event_spec.coffee @@ -92,6 +92,15 @@ describe 'events', -> payload = job: 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 url: '/jobs/15' @@ -105,12 +114,6 @@ describe 'events', -> 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' } waits(100) runs -> diff --git a/assets/scripts/spec/spec_helper.coffee b/assets/scripts/spec/spec_helper.coffee index 089061de..5e1f2fe5 100644 --- a/assets/scripts/spec/spec_helper.coffee +++ b/assets/scripts/spec/spec_helper.coffee @@ -22,7 +22,7 @@ minispade.require 'app' runs -> url = "/#{url}" if url && !url.match(/^\//) Travis.app.router.route(url) - waits 100 + waits 500 runs -> foo = 'bar' diff --git a/assets/scripts/spec/unit/incomplete_spec.coffee b/assets/scripts/spec/unit/incomplete_spec.coffee new file mode 100644 index 00000000..86ef35df --- /dev/null +++ b/assets/scripts/spec/unit/incomplete_spec.coffee @@ -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() diff --git a/public/scripts/specs.js b/public/scripts/specs.js index bb2672d5..42f18d67 100644 --- a/public/scripts/specs.js +++ b/public/scripts/specs.js @@ -8443,7 +8443,18 @@ return sinon;}.call(typeof window != 'undefined' && window || {})); var payload; payload = { 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({ @@ -8457,15 +8468,7 @@ return sinon;}.call(typeof window != 'undefined' && window || {})); 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' - } + commit_id: 1 } }); }); @@ -8847,7 +8850,7 @@ return sinon;}.call(typeof window != 'undefined' && window || {})); url = "/" + url; } Travis.app.router.route(url); - waits(100); + waits(500); return runs(function() { var foo; return foo = 'bar'; diff --git a/public/version b/public/version index 272a94a3..bda1e591 100644 --- a/public/version +++ b/public/version @@ -1 +1 @@ -e090359a \ No newline at end of file +402ce94f \ No newline at end of file