-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #3252 - Turbo87:published-by, r=locks
models/version: Add `published_by` relationship For the more recent releases the crates.io backend now records who published the release and returns that information on the API. It would be useful to eventually show this data either in the versions list or on the version details page. This PR adds a corresponding `published_by` relationship to the `version` model to make this data generally available in the frontend.
- Loading branch information
Showing
7 changed files
with
75 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { EmbeddedRecordsMixin } from '@ember-data/serializer/rest'; | ||
|
||
import ApplicationSerializer from './application'; | ||
|
||
export default ApplicationSerializer.extend(EmbeddedRecordsMixin, { | ||
attrs: { | ||
published_by: { embedded: 'always' }, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { setupTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; | ||
|
||
module('Model | Version', function (hooks) { | ||
setupTest(hooks); | ||
setupMirage(hooks); | ||
|
||
hooks.beforeEach(function () { | ||
this.store = this.owner.lookup('service:store'); | ||
}); | ||
|
||
test('`published_by` relationship is assigned correctly', async function (assert) { | ||
let user = this.server.create('user', { name: 'JD' }); | ||
|
||
let crate = this.server.create('crate'); | ||
this.server.create('version', { crate, publishedBy: user }); | ||
|
||
let crateRecord = await this.store.findRecord('crate', crate.id); | ||
assert.ok(crateRecord); | ||
let versions = (await crateRecord.versions).toArray(); | ||
assert.equal(versions.length, 1); | ||
let version = versions[0]; | ||
assert.ok(version.published_by); | ||
assert.equal(version.published_by.name, 'JD'); | ||
}); | ||
}); |