forked from TryGhost/Admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial members model and associated mirage setup
no issue - mirage is now enabled by default in development with logging (can be turned off once we're no longer relying on mocked members endpoints)
- Loading branch information
1 parent
21d811b
commit 8e734d3
Showing
8 changed files
with
55 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import DS from 'ember-data'; | ||
import attr from 'ember-data/attr'; | ||
|
||
export default DS.Model.extend({ | ||
name: attr('string'), | ||
email: attr('string'), | ||
createdAt: attr('moment-utc') | ||
}); |
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import AuthenticatedRoute from 'ghost-admin/routes/authenticated'; | ||
|
||
export default AuthenticatedRoute.extend({}); | ||
export default AuthenticatedRoute.extend({ | ||
model() { | ||
return this.store.findAll('member'); | ||
} | ||
}); |
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,5 @@ | ||
import {paginatedResponse} from '../utils'; | ||
|
||
export default function mockMembers(server) { | ||
server.get('/members/', paginatedResponse('members')); | ||
} |
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,12 @@ | ||
import moment from 'moment'; | ||
import {Factory, faker} from 'ember-cli-mirage'; | ||
|
||
let randomDate = function randomDate(start = moment().subtract(30, 'days').toDate(), end = new Date()) { | ||
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime())); | ||
}; | ||
|
||
export default Factory.extend({ | ||
name() { return `${faker.name.firstName()} ${faker.name.lastName()}`; }, | ||
email: faker.internet.email, | ||
createdAt() { return randomDate(); } | ||
}); |
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,4 @@ | ||
import {Model} from 'ember-cli-mirage'; | ||
|
||
export default Model.extend({ | ||
}); |
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,14 @@ | ||
import {describe, it} from 'mocha'; | ||
import {expect} from 'chai'; | ||
import {setupTest} from 'ember-mocha'; | ||
|
||
describe('Unit: Model: member', function () { | ||
setupTest(); | ||
|
||
// Replace this with your real tests. | ||
it('exists', function () { | ||
let store = this.owner.lookup('service:store'); | ||
let model = store.createRecord('member', {}); | ||
expect(model).to.be.ok; | ||
}); | ||
}); |