diff --git a/app/controllers/owner.coffee b/app/controllers/owner.coffee index 5332c86d..44cf321e 100644 --- a/app/controllers/owner.coffee +++ b/app/controllers/owner.coffee @@ -34,9 +34,19 @@ Controller = Ember.Controller.extend repos = data.repositories.filter (item, index) -> if item.active && item.default_branch.last_build != null - item.active + item + repos - console.log(repos) + ).property('model') + + running: (-> + data = @get('model') + + repos = data.repositories.filter (item, index) -> + if item.active + if item.default_branch.last_build != null + if item.default_branch.last_build.state == 'started' + item repos ).property('model') diff --git a/app/templates/components/owner-repo-tile.hbs b/app/templates/components/owner-repo-tile.hbs index 2910110f..5e866192 100644 --- a/app/templates/components/owner-repo-tile.hbs +++ b/app/templates/components/owner-repo-tile.hbs @@ -18,7 +18,7 @@ {{/link-to}}

{{format-sha repo.default_branch.last_build.commit.sha}}

-

+

{{format-duration repo.default_branch.last_build.duration}}

diff --git a/app/templates/owner.hbs b/app/templates/owner.hbs index 7d06105a..a1d0e0d3 100644 --- a/app/templates/owner.hbs +++ b/app/templates/owner.hbs @@ -30,38 +30,19 @@

diff --git a/tests/unit/components/owner-repo-tile-test.coffee b/tests/unit/components/owner-repo-tile-test.coffee index 70577e00..d2afbfc0 100644 --- a/tests/unit/components/owner-repo-tile-test.coffee +++ b/tests/unit/components/owner-repo-tile-test.coffee @@ -2,16 +2,44 @@ moduleForComponent 'owner-repo-tile', 'OwnerRepoTileComponent', { # specify the other units that are required for this test - # needs: ['component:foo', 'helper:bar'] + needs: ['helper:format-time', 'helper:format-duration', 'helper:format-sha'] } test 'it renders', -> - expect 2 - # creates the component instance - component = @subject() - equal component._state, 'preRender' + attributes = { + slug: "travis-ci/travis-chat", + active: false, + private: false, + default_branch: { + name: "master", + last_build: { + number: "25", + state: "passed", + duration: 252, + event_type: "push", + previous_state: "passed", + started_at: "2013-07-08T11:03:19Z", + finished_at: "2013-07-08T11:06:50Z", + commit: { + sha: "16fff347ff55403caf44c53357855ebc32adf95d", + compare_url: "https://github.com/travis-ci/travis-chat/compare/3c4e9ea50141...16fff347ff55", + } + } + } + } + + + component = @subject(repo: attributes) - # appends the component to the page @append() - equal component._state, 'inDOM' + + ok component.$().hasClass('passed'), 'component should have state class (passed)' + ok component.$('.icon-status').hasClass('passed'), 'status icon should have state class (passed)' + ok component.$('.request-kind').hasClass('push'), 'reuqest icon should have event type class (push)' + equal component.$('.tile-main h3').text().trim(), 'travis-ci', 'should display correct owner name' + equal component.$('.tile-main h2 a').text().trim(), 'travis-chat', 'should display correct repo name' + equal component.$('.build-status a').text().trim(), '25 passed', 'should display correct build number and state' + equal component.$('.tile-commit a').text().trim(), '16fff34', 'should display correct commit sha' + equal component.$('.tile-timeago').text().trim(), '2 years ago', 'should display correct build duration' + equal component.$('.tile-duration').text().trim(), '4 min 12 sec', 'should display correct build finished at time'