diff --git a/app/controllers/crate/version.js b/app/controllers/crate/version.js index e6ef1252ea2..1f71a8baf4a 100644 --- a/app/controllers/crate/version.js +++ b/app/controllers/crate/version.js @@ -70,9 +70,19 @@ export default Controller.extend({ } return PromiseArray.create({ - promise: deps.then(deps => { - return deps.filter(dep => dep.get('kind') !== 'dev').uniqBy('crate_id'); - }), + promise: deps.then(deps => deps.filterBy('kind', 'normal').uniqBy('crate_id')), + }); + }), + + currentBuildDependencies: computed('currentVersion.dependencies', function() { + let deps = this.get('currentVersion.dependencies'); + + if (deps === null) { + return []; + } + + return PromiseArray.create({ + promise: deps.then(deps => deps.filterBy('kind', 'build').uniqBy('crate_id')), }); }), @@ -82,9 +92,7 @@ export default Controller.extend({ return []; } return PromiseArray.create({ - promise: deps.then(deps => { - return deps.filterBy('kind', 'dev'); - }), + promise: deps.then(deps => deps.filterBy('kind', 'dev').uniqBy('crate_id')), }); }), diff --git a/app/templates/crate/version.hbs b/app/templates/crate/version.hbs index 4199a9ef046..6003d45683a 100644 --- a/app/templates/crate/version.hbs +++ b/app/templates/crate/version.hbs @@ -217,6 +217,17 @@ + {{#if currentBuildDependencies}} +
+

Build-Dependencies

+ +
+ {{/if}} + {{#if currentDevDependencies}}

Dev-Dependencies

diff --git a/mirage/fixtures/dependencies.js b/mirage/fixtures/dependencies.js index 9f7cb4a8390..372b4100483 100644 --- a/mirage/fixtures/dependencies.js +++ b/mirage/fixtures/dependencies.js @@ -26,11 +26,33 @@ export default [ crate_id: 'nanomsg', default_features: true, features: '', - id: 90880, + id: 146233, kind: 'normal', optional: false, req: '^0.5.0', target: null, version_id: 28674, }, + { + crate_id: 'mock-build-deps', + default_features: true, + features: '', + id: 146234, + kind: 'build', + optional: false, + req: '^0.6.1', + target: null, + version_id: 40905, + }, + { + crate_id: 'mock-dev-deps', + default_features: true, + features: '', + id: 146235, + kind: 'dev', + optional: true, + req: '^0.6.1', + target: null, + version_id: 40905, + }, ]; diff --git a/tests/acceptance/crate-test.js b/tests/acceptance/crate-test.js index c1f53492cdd..3bab3e97591 100644 --- a/tests/acceptance/crate-test.js +++ b/tests/acceptance/crate-test.js @@ -154,6 +154,30 @@ module('Acceptance | crate page', function(hooks) { assert.dom('[data-test-heading] [data-test-team-name]').hasText('thehydroimpulseteam'); }); + test('crates having normal dependencies', async function(assert) { + this.server.loadFixtures(); + + await visit('crates/nanomsg'); + + assert.dom('#crate-dependencies li').exists({ count: 2 }); + }); + + test('crates having build dependencies', async function(assert) { + this.server.loadFixtures(); + + await visit('crates/nanomsg'); + + assert.dom('#crate-build-dependencies li').exists({ count: 1 }); + }); + + test('crates having dev dependencies', async function(assert) { + this.server.loadFixtures(); + + await visit('crates/nanomsg'); + + assert.dom('#crate-dev-dependencies li').exists({ count: 1 }); + }); + test('crates having user-owners', async function(assert) { this.server.loadFixtures();