Skip to content

Commit bf34146

Browse files
committed
mirage/crate: Replace _owner_teams property with teamOwners relationship
1 parent be1d985 commit bf34146

File tree

6 files changed

+5
-6
lines changed

6 files changed

+5
-6
lines changed

mirage/factories/crate.js

-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ export default Factory.extend({
2424

2525
badges: () => [],
2626
_extra_downloads: () => [],
27-
_owner_teams: () => [],
2827
});

mirage/fixtures/crates.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default [
5757
downloads: 14,
5858
},
5959
],
60-
_owner_teams: [1, 303],
60+
teamOwnerIds: [1, 303],
6161
userOwnerIds: [2, 303],
6262
},
6363
{

mirage/models/crate.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Model, hasMany } from 'ember-cli-mirage';
33
export default Model.extend({
44
categories: hasMany(),
55
keywords: hasMany(),
6+
teamOwners: hasMany('team'),
67
versions: hasMany(),
78
userOwners: hasMany('user'),
89
});

mirage/route-handlers/crates.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ export function register(server) {
113113
let crate = schema.crates.find(crateId);
114114
if (!crate) return notFound();
115115

116-
let teams = schema.teams.find(crate._owner_teams);
117-
118-
let response = this.serialize(teams);
116+
let response = this.serialize(crate.teamOwners);
119117

120118
response.teams.forEach(team => {
121119
team.kind = 'team';

mirage/serializers/crate.js

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export default BaseSerializer.extend({
5555
hash.versions = hash.version_ids;
5656
delete hash.version_ids;
5757

58+
delete hash.team_owner_ids;
5859
delete hash.user_owner_ids;
5960
},
6061
});

tests/mirage/crates-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ module('Mirage | Keywords', function(hooks) {
690690

691691
test('returns the list of teams that own the specified crate', async function(assert) {
692692
let team = this.server.create('team', { name: 'maintainers' });
693-
this.server.create('crate', { name: 'rand', _owner_teams: [team.id] });
693+
this.server.create('crate', { name: 'rand', teamOwners: [team] });
694694

695695
let response = await fetch('/api/v1/crates/rand/owner_team');
696696
assert.equal(response.status, 200);

0 commit comments

Comments
 (0)