diff --git a/app/models/crate.js b/app/models/crate.js index 106fc516aa0..67ed18cf4c3 100644 --- a/app/models/crate.js +++ b/app/models/crate.js @@ -15,7 +15,6 @@ export default DS.Model.extend({ issues: DS.attr('string'), documentation: DS.attr('string'), repository: DS.attr('string'), - license: DS.attr('string'), exact_match: DS.attr('boolean'), versions: DS.hasMany('versions', { async: true }), diff --git a/app/models/version.js b/app/models/version.js index 913f6836b73..47741e582f5 100644 --- a/app/models/version.js +++ b/app/models/version.js @@ -8,6 +8,7 @@ export default DS.Model.extend({ updated_at: DS.attr('date'), downloads: DS.attr('number'), yanked: DS.attr('boolean'), + license: DS.attr('string'), crate: DS.belongsTo('crate', { async: false diff --git a/app/templates/crate/version.hbs b/app/templates/crate/version.hbs index 93386d75dc8..2f159bc99e7 100644 --- a/app/templates/crate/version.hbs +++ b/app/templates/crate/version.hbs @@ -124,10 +124,10 @@
- {{#if crate.license}} + {{#if currentVersion.license}}

License

-

{{ crate.license }}

+

{{ currentVersion.license }}

{{/if}} diff --git a/mirage/factories/crate.js b/mirage/factories/crate.js index 97c400bde4c..b5a03a7c678 100644 --- a/mirage/factories/crate.js +++ b/mirage/factories/crate.js @@ -14,7 +14,6 @@ export default Factory.extend({ documentation: () => faker.internet.url(), homepage: () => faker.internet.url(), repository: () => faker.internet.url(), - license: () => faker.hacker.abbreviation(), max_version: () => faker.system.semver(), created_at: () => faker.date.past(), diff --git a/mirage/factories/version.js b/mirage/factories/version.js index 3e8165a7454..0dacaa6285e 100644 --- a/mirage/factories/version.js +++ b/mirage/factories/version.js @@ -13,6 +13,7 @@ export default Factory.extend({ }, yanked: false, + license: () => faker.hacker.abbreviation(), dl_path() { return `/api/v1/crates/${this.crate}/${this.num}/download`; diff --git a/mirage/fixtures/crates.js b/mirage/fixtures/crates.js index d188c0ada31..2bb1d4ea037 100644 --- a/mirage/fixtures/crates.js +++ b/mirage/fixtures/crates.js @@ -11,7 +11,6 @@ export default [{ "keywords": [ "network", ], - "license": "MIT", "max_version": "0.7.0-alpha", "name": "nanomsg", "repository": "https://github.com/thehydroimpulse/nanomsg.rs", @@ -52,7 +51,6 @@ export default [{ "homepage": "https://github.com/huonw/external_mixin", "id": "rust_mixin", "keywords": ["rust", "plugin", "code-generation"], - "license": "MIT/Apache-2.0", "max_version": "0.0.1", "name": "rust_mixin", "repository": "https://github.com/huonw/external_mixin", @@ -114,7 +112,6 @@ export default [{ "homepage": "https://github.com/huonw/external_mixin", "id": "external_mixin", "keywords": ["python", "ruby", "shell", "plugin", "code-generation"], - "license": "MIT/Apache-2.0", "max_version": "0.0.1", "name": "external_mixin", "repository": "https://github.com/huonw/external_mixin", @@ -128,7 +125,6 @@ export default [{ "homepage": "https://github.com/huonw/external_mixin", "id": "external_mixin_umbrella", "keywords": ["plugin", "code-generation"], - "license": "MIT/Apache-2.0", "max_version": "0.0.2", "name": "external_mixin_umbrella", "repository": "https://github.com/huonw/external_mixin", @@ -142,7 +138,6 @@ export default [{ "homepage": "https://github.com/whatisinternet/inflector", "id": "Inflector", "keywords": ["string", "case", "camel", "snake", "inflection"], - "license": "BSD-2-Clause", "max_version": "0.1.6", "name": "Inflector", "repository": "https://github.com/whatisinternet/inflector", @@ -156,7 +151,6 @@ export default [{ "homepage": null, "id": "rs-es", "keywords": ["elasticsearch", "elastic"], - "license": "Apache-2.0", "max_version": "0.1.17", "name": "rs-es", "repository": "https://github.com/benashford/rs-es", @@ -170,7 +164,6 @@ export default [{ "homepage": "https://github.com/DaGenix/rust-crypto/", "id": "rust-crypto", "keywords": ["Crypto", "MD5", "Sha1", "Sha2", "AES"], - "license": "MIT/Apache-2.0", "max_version": "0.2.34", "name": "rust-crypto", "repository": "https://github.com/DaGenix/rust-crypto/", @@ -184,7 +177,6 @@ export default [{ "homepage": null, "id": "rust-htslib", "keywords": ["htslib", "bam", "bioinformatics", "pileup", "sequencing"], - "license": "MIT", "max_version": "0.5.2", "name": "rust-htslib", "repository": "https://github.com/rust-bio/rust-htslib.git", @@ -198,7 +190,6 @@ export default [{ "homepage": "https://icorderi.github.io/icorderi/kinetic-rust", "id": "kinetic-rust", "keywords": ["Protocol", "Kinetic", "Storage"], - "license": "MIT", "max_version": "0.0.16", "name": "kinetic-rust", "repository": "https://github.com/icorderi/kinetic-rust/", @@ -212,7 +203,6 @@ export default [{ "homepage": "https://github.com/rustless/rustless", "id": "rustless", "keywords": ["api", "web", "hyper", "iron", "rest"], - "license": "MIT", "max_version": "0.8.0", "name": "rustless", "repository": "https://crates.io/crates/rustless", @@ -226,7 +216,6 @@ export default [{ "homepage": null, "id": "serde", "keywords": ["serde", "serialization"], - "license": "MIT/Apache-2.0", "max_version": "0.6.1", "name": "serde", "repository": "https://github.com/serde-rs/serde", @@ -240,7 +229,6 @@ export default [{ "homepage": "https://github.com/livioribeiro/rusted-cypher", "id": "rusted_cypher", "keywords": ["neo4j", "database", "query", "cypher", "graph"], - "license": "MIT", "max_version": "0.7.1", "name": "rusted_cypher", "repository": "https://github.com/livioribeiro/rusted-cypher", @@ -254,7 +242,6 @@ export default [{ "homepage": null, "id": "zlib", "keywords": [], - "license": "MIT", "max_version": "0.0.1", "name": "zlib", "repository": null, @@ -268,7 +255,6 @@ export default [{ "homepage": null, "id": "rustful", "keywords": ["web", "rest", "framework", "http", "routing"], - "license": "MIT", "max_version": "0.5.0", "name": "rustful", "repository": "https://github.com/Ogeon/rustful", @@ -282,7 +268,6 @@ export default [{ "homepage": null, "id": "postgres", "keywords": ["database", "sql"], - "license": "MIT", "max_version": "0.10.1", "name": "postgres", "repository": "https://github.com/sfackler/rust-postgres", @@ -296,7 +281,6 @@ export default [{ "homepage": "https://github.com/BurntSushi/quickcheck", "id": "quickcheck", "keywords": ["testing", "quickcheck", "property", "shrinking", "fuzz"], - "license": "Unlicense/MIT", "max_version": "0.2.24", "name": "quickcheck", "repository": "https://github.com/BurntSushi/quickcheck", @@ -310,7 +294,6 @@ export default [{ "homepage": "https://github.com/BurntSushi/quickcheck", "id": "quickcheck_macros", "keywords": ["testing", "quickcheck", "property", "shrinking", "fuzz"], - "license": "Unlicense/MIT", "max_version": "0.2.24", "name": "quickcheck_macros", "repository": "https://github.com/BurntSushi/quickcheck", @@ -324,7 +307,6 @@ export default [{ "homepage": "https://github.com/nicolas-cherel/rustlex", "id": "nc_rustlex", "keywords": ["lexer", "lexical", "analyser", "generator"], - "license": "MIT", "max_version": "0.3.1", "name": "nc_rustlex", "repository": "https://github.com/nicolas-cherel/rustlex", @@ -338,7 +320,6 @@ export default [{ "homepage": null, "id": "nom", "keywords": ["parser", "parser-combinators", "parsing", "streaming", "bit"], - "license": "MIT", "max_version": "1.0.1", "name": "nom", "repository": "https://github.com/Geal/nom", diff --git a/mirage/fixtures/versions.js b/mirage/fixtures/versions.js index 383606a4e13..6237099a352 100644 --- a/mirage/fixtures/versions.js +++ b/mirage/fixtures/versions.js @@ -13,6 +13,7 @@ export default [{ "num": "0.7.0-alpha.1", "updated_at": "2016-12-27T08:40:00Z", "yanked": false, + "license": "MIT", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -37,6 +38,7 @@ export default [{ "num": "0.6.1", "updated_at": "2016-12-27T08:40:00Z", "yanked": false, + "license": "Apache-2.0", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -58,6 +60,7 @@ export default [{ "num": "0.6.0", "updated_at": "2016-06-10T20:03:55Z", "yanked": false, + "license": "Apache-2.0", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -79,6 +82,7 @@ export default [{ "num": "0.5.0", "updated_at": "2016-01-24T22:07:58Z", "yanked": false, + "license": "MIT/Apache-2.0", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -100,6 +104,7 @@ export default [{ "num": "0.4.2", "updated_at": "2015-12-16T00:01:56Z", "yanked": false, + "license": "MIT", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -121,6 +126,7 @@ export default [{ "num": "0.4.1", "updated_at": "2015-12-11T23:54:29Z", "yanked": false, + "license": "MIT", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -142,6 +148,7 @@ export default [{ "num": "0.4.0", "updated_at": "2015-12-11T23:54:29Z", "yanked": false, + "license": "MIT", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -163,6 +170,7 @@ export default [{ "num": "0.3.4", "updated_at": "2015-12-15T00:03:39Z", "yanked": false, + "license": "MIT", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -184,6 +192,7 @@ export default [{ "num": "0.3.3", "updated_at": "2015-12-11T23:54:29Z", "yanked": false, + "license": "MIT", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -205,6 +214,7 @@ export default [{ "num": "0.3.2", "updated_at": "2015-12-11T23:54:29Z", "yanked": false, + "license": "Apache-2.0", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -226,6 +236,7 @@ export default [{ "num": "0.3.1", "updated_at": "2015-12-11T23:54:29Z", "yanked": false, + "license": "MIT/Apache-2.0", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -247,6 +258,7 @@ export default [{ "num": "0.3.0", "updated_at": "2015-12-11T23:54:29Z", "yanked": false, + "license": "MIT", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -268,6 +280,7 @@ export default [{ "num": "0.2.0", "updated_at": "2015-12-11T23:54:29Z", "yanked": false, + "license": "MIT", "_authors": [ "Daniel Fagnan ", "Jason E. Aten", @@ -289,6 +302,7 @@ export default [{ "num": "0.2.0", "updated_at": "2015-12-11T23:54:29Z", "yanked": false, + "license": "MIT", "_authors": [ "David C. Bishop", ] diff --git a/mirage/serializers/crate.js b/mirage/serializers/crate.js index 5e2a6bc411c..fca074d67af 100644 --- a/mirage/serializers/crate.js +++ b/mirage/serializers/crate.js @@ -11,7 +11,6 @@ export default BaseSerializer.extend({ 'homepage', 'id', 'keywords', - 'license', 'links', 'max_version', 'name', diff --git a/mirage/serializers/version.js b/mirage/serializers/version.js index b01504f6326..e8079d30f3e 100644 --- a/mirage/serializers/version.js +++ b/mirage/serializers/version.js @@ -12,6 +12,7 @@ export default BaseSerializer.extend({ 'num', 'updated_at', 'yanked', + 'license', ], links(version) { diff --git a/src/krate.rs b/src/krate.rs index 1e834d29c9e..1aaec5f4418 100644 --- a/src/krate.rs +++ b/src/krate.rs @@ -104,7 +104,6 @@ pub struct EncodableCrate { pub description: Option, pub homepage: Option, pub documentation: Option, - pub license: Option, pub repository: Option, pub links: CrateLinks, pub exact_match: bool, @@ -507,7 +506,6 @@ impl Crate { homepage, documentation, repository, - license, .. } = self; let versions_link = match versions { @@ -533,7 +531,6 @@ impl Crate { exact_match: exact_match, description: description, repository: repository, - license: license, links: CrateLinks { version_downloads: format!("/api/v1/crates/{}/downloads", name), versions: versions_link, diff --git a/tests/acceptance/crate-test.js b/tests/acceptance/crate-test.js index 0a5a6e5a1f9..ab57ee90b52 100644 --- a/tests/acceptance/crate-test.js +++ b/tests/acceptance/crate-test.js @@ -119,3 +119,12 @@ test('crates having team-owners', async function(assert) { findWithAssert('ul.owners li:first a[href="/teams/github:org:thehydroimpulse"]'); assert.equal(find('ul.owners li').length, 4); }); + +test('crates license is supplied by version', async function(assert) { + server.loadFixtures(); + + await visit('/crates/nanomsg'); + hasText(assert, '.license', 'Apache-2.0'); + await click('#crate-versions a:contains("0.5.0")'); + hasText(assert, '.license', 'MIT/Apache-2.0'); +});