Last active
August 15, 2017 15:50
-
-
Save rossjha/32089ecd37400b241d521eb8f2acd6a3 to your computer and use it in GitHub Desktop.
Tags
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
import Ember from 'ember'; | |
const { Route: EmberRoute } = Ember; | |
export default EmberRoute.extend({ | |
// Defaults | |
// Single line CP | |
// Multiline CP | |
// Private | |
// Lifecycle hooks | |
afterModel() { | |
this.replaceWith('users'); | |
} | |
}); |
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
import Ember from 'ember'; | |
const { Component: EmberComponent } = Ember; | |
export default EmberComponent.extend({ | |
// Defaults | |
// Single line CP | |
// Multiline CP | |
// Private | |
// Lifecycle hooks | |
}); |
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
import Ember from 'ember'; | |
const { Component: EmberComponent } = Ember; | |
const { computed } = Ember; | |
export default EmberComponent.extend({ | |
// Defaults | |
users: computed.alias('model') | |
// Single line CP | |
// Multiline CP | |
// Private | |
// Lifecycle hooks | |
}); |
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
export default function() { | |
this.get('users'); | |
this.get('users/:id'); | |
}; |
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
import { Factory, faker } from 'ember-cli-mirage'; | |
export default Factory.extend({ | |
createdAt: '2017-01-01T00:00:00.000Z', | |
firstName() { | |
return faker.name.firstName(); | |
}, | |
lastName() { | |
return faker.name.lastName(); | |
}, | |
email() { | |
return `${this.firstName.toLowerCase()}.${this.lastName.toLowerCase()}@acme.com`; | |
}, | |
updatedAt: '2017-01-01T00:00:00.000Z', | |
updatedBy: 'admin.user', | |
name() { | |
return `${this.firstName} ${this.lastName}`; | |
} | |
}); |
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
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
export default function(server) { | |
// added this line because global wasn't created otherwise. | |
let user = server.createList('user', 10); | |
} |
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
import { JSONAPISerializer } from 'ember-cli-mirage'; | |
export default JSONAPISerializer.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
import Model from 'ember-data/model'; | |
import attr from 'ember-data/attr'; | |
const { computed, get } = Ember; | |
export const schema = { | |
// Attributes | |
createdAt: attr('date', { | |
defaultValue() { | |
return new Date(); | |
} | |
}), | |
email: attr('string'), | |
firstName: attr('string'), | |
lastName: attr('string'), | |
updatedAt: attr('date', { | |
defaultValue() { | |
return new Date(); | |
} | |
}), | |
updatedBy: attr('string'), | |
// Associations | |
// Computed Properties | |
name: computed('firstName', 'lastName', function() { | |
return `${get(this, 'firstName')} ${get(this, 'lastName')}`; | |
}) | |
}; | |
export default Model.extend(schema); |
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
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('users'); | |
}); | |
export default Router; |
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
/* Layout */ | |
* { | |
box-sizing: border-box; | |
margin: 0; | |
padding: 0; | |
} | |
html, body { | |
color: #444; | |
font-family: 'Roboto', sans-serif; | |
font-size: 100%; | |
} | |
.container{ | |
max-width: 960px; | |
margin: 0 auto; | |
} | |
/* Type */ | |
.Tags input[type='text'] { | |
padding: 10px; | |
border: 1px solid #ccc; | |
border-radius: 3px; | |
min-width: 400px; | |
margin: 30px 0; | |
} | |
.Tabs ul{ | |
margin: 0; | |
padding: 0; | |
} | |
.Tabs ul{ | |
border: 1px solid #ccc; | |
border-radius: 3px; | |
} | |
.Tabs ul:after{ | |
display: table; | |
clear: both; | |
content: ''; | |
} | |
.Tags ul li{ | |
list-style: none; | |
display: inline; | |
padding: 5px 20px; | |
background: #ccc; | |
border-radius: 3px; | |
font-size: 0.9em; | |
position: relative; | |
margin-right: 10px; | |
} | |
.Tags li span{ | |
position: absolute; | |
top: 1px; | |
right: 5px; | |
display: none; | |
} | |
.Tags li:hover span{ | |
display: block; | |
cursor: pointer; | |
} |
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
import Ember from 'ember'; | |
export default function destroyApp(application) { | |
Ember.run(application, 'destroy'); | |
} |
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
import { module } from 'qunit'; | |
import startApp from '../helpers/start-app'; | |
import destroyApp from '../helpers/destroy-app'; | |
export default function(name, options = {}) { | |
module(name, { | |
beforeEach() { | |
this.application = startApp(); | |
if (options.beforeEach) { | |
options.beforeEach.apply(this, arguments); | |
} | |
}, | |
afterEach() { | |
if (options.afterEach) { | |
options.afterEach.apply(this, arguments); | |
} | |
destroyApp(this.application); | |
} | |
}); | |
} |
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
import Resolver from '../../resolver'; | |
import config from '../../config/environment'; | |
const resolver = Resolver.create(); | |
resolver.namespace = { | |
modulePrefix: config.modulePrefix, | |
podModulePrefix: config.podModulePrefix | |
}; | |
export default resolver; |
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
import Ember from 'ember'; | |
import Application from '../../app'; | |
import config from '../../config/environment'; | |
export default function startApp(attrs) { | |
let application; | |
let attributes = Ember.merge({rootElement: "#test-root"}, config.APP); | |
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; | |
Ember.run(() => { | |
application = Application.create(attributes); | |
application.setupForTesting(); | |
application.injectTestHelpers(); | |
}); | |
return application; | |
} |
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
import resolver from './helpers/resolver'; | |
import { | |
setResolver | |
} from 'ember-qunit'; | |
setResolver(resolver); |
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
{ | |
"version": "0.10.4", | |
"ENV": { | |
"ember-cli-mirage": { | |
"enabled": true | |
} | |
}, | |
"EmberENV": { | |
"FEATURES": { | |
"ds-finder-include": true | |
} | |
}, | |
"options": { | |
"use_pods": true | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.10.2", | |
"ember-data": "2.11.0", | |
"ember-template-compiler": "2.10.2" | |
}, | |
"addons": { | |
"ember-cli-mirage": "0.2.4" | |
} | |
} |
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
import Ember from 'ember'; | |
const { Controller } = Ember; | |
export default Controller.extend({ | |
// Defaults | |
tags: [{ | |
name: 'Tag I' | |
}, { | |
name: 'Tag II' | |
}, { | |
name: 'Tag III' | |
}] | |
// Single line CP | |
// Multiline CP | |
// Private | |
// Lifecycle hooks | |
}); |
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
import Ember from 'ember'; | |
const { Route: EmberRoute } = Ember; | |
export default EmberRoute.extend({ | |
// Defaults | |
// Single line CP | |
// Multiline CP | |
// Private | |
// Lifecycle hooks | |
model() { | |
return this.store.findAll('user'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment