Last active
January 31, 2018 17:23
-
-
Save magistrula/7362b829040e64cad606b8a49f83ea68 to your computer and use it in GitHub Desktop.
Student Grouper
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'; | |
// Computed Properties: https://emberjs.com/api/ember/2.15/namespaces/Ember.computed | |
export default Ember.Controller.extend({ | |
allStudents: Ember.computed.reads('model') | |
}); |
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 Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
export default Model.extend({ | |
name: attr('string'), | |
age: attr('number'), | |
independent: attr('bool'), | |
supportive: attr('bool'), | |
zesty: attr('bool'), | |
is13OrOlder: Ember.computed.gte('age', 13) | |
}); |
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 ART = 'art'; | |
const DANCE = 'dance'; | |
const MUSIC = 'music'; | |
const SOCCER = 'soccer'; | |
const BASKETBALL = 'basketball'; | |
const BASEBALL = 'baseball'; | |
const STUDENT_ATTRS = [ | |
{ | |
name: 'Barney McAllister', | |
age: 12, | |
independent: true, | |
supportive: false, | |
zesty: false, | |
interests: [ART, SOCCER] | |
}, | |
{ | |
name: 'Aramazd Hovsepian', | |
age: 11, | |
independent: false, | |
supportive: false, | |
zesty: true, | |
interests: [MUSIC, BASKETBALL] | |
}, | |
{ | |
name: 'Christian McCarthy', | |
age: 13, | |
independent: true, | |
supportive: true, | |
zesty: true, | |
interests: [ART, DANCE] | |
}, | |
{ | |
name: 'Massis Sepanian', | |
age: 13, | |
independent: false, | |
supportive: false, | |
zesty: false, | |
interests: [SOCCER, BASKETBALL] | |
}, | |
{ | |
name: 'Sophia Geragosian', | |
age: 11, | |
independent: true, | |
supportive: false, | |
zesty: true, | |
interests: [BASEBALL, MUSIC] | |
}, | |
{ | |
name: 'Conor O\'Malley', | |
age: 13, | |
independent: false, | |
supportive: true, | |
zesty: false, | |
interests: [DANCE, BASKETBALL] | |
}, | |
{ | |
name: 'Vahag Hovanessian', | |
age: 12, | |
independent: true, | |
supportive: false, | |
zesty: false, | |
interests: [ART, BASKETBALL] | |
}, | |
{ | |
name: 'Anne O\'Shea', | |
age: 11, | |
independent: false, | |
supportive: false, | |
zesty: true, | |
interests: [MUSIC, SOCCER] | |
}, | |
{ | |
name: 'Courtney McBride', | |
age: 11, | |
independent: true, | |
supportive: true, | |
zesty: true, | |
interests: [BASEBALL, DANCE] | |
}, | |
{ | |
name: 'Baleny Baharian', | |
age: 13, | |
independent: false, | |
supportive: false, | |
zesty: false, | |
interests: [MUSIC, DANCE] | |
}, | |
{ | |
name: 'Arsineh Hayrapetian', | |
age: 12, | |
independent: true, | |
supportive: false, | |
zesty: true, | |
interests: [SOCCER, ART] | |
}, | |
{ | |
name: 'Susanna O\'Brien', | |
age: 13, | |
independent: false, | |
supportive: true, | |
zesty: false, | |
interests: [ART, MUSIC] | |
}, | |
]; | |
export default Ember.Route.extend({ | |
model() { | |
// Create a student model: | |
// this.get('store').createRecord('student', { name: 'Foo'}); | |
} | |
}); |
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 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'; | |
const { run } = Ember; | |
const assign = Ember.assign || Ember.merge; | |
export default function startApp(attrs) { | |
let application; | |
let attributes = assign({rootElement: "#test-root"}, config.APP); | |
attributes = assign(attributes, attrs); // use defaults, but you can override; | |
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
import { moduleFor, test } from 'ember-qunit'; | |
// https://api.qunitjs.com/config/QUnit.assert | |
moduleFor('controller:application', 'TODO: put something here', { | |
// Specify the other units that are required for this test. | |
// needs: ['controller:foo'] | |
}); | |
test('sortedStudents alphabetizes the students', function(assert) { | |
let controller = this.subject({ | |
model: [ | |
{ name: 'Student B' }, | |
{ name: 'Student C' }, | |
{ name: 'Student A' } | |
] | |
}); | |
assert.deepEqual(controller.get('sortedStudents'), [ | |
{ name: 'Student A'}, | |
{ name: 'Student B'}, | |
{ name: 'Student C'} | |
]); | |
}); |
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.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment