Skip to content

Instantly share code, notes, and snippets.

@ianpetzer
ianpetzer / gist:5724178
Created June 6, 2013 19:24
proc for Assetfile to ensure Ember templates get the correct name
ember_template_name_proc = proc { |input|
dir = File.dirname(input.path)
dir = dir.sub!('templates/', '')
template_name = File.basename(input.path, File.extname(input.path))
template_name = dir + '/' + template_name if !dir.nil?
template_name
}
App.CategoriesRoute = Ember.Route.extend({
model: function() {
return App.Category.find();
}
});
{{#each model}}
//List all categories here
{{/each}}
{{#each filteredCategories}}
//List filtered categories here
{{/each}}
App.CategoriesController = Ember.Array.extend({
filteredCategories: function() {
var filter = 'String value to compare lower case name to. ';
return this.get('model').filterProperty('nameLowerCase', filter);
}.property('model.@each.nameLowerCase')
});
App.Category = Ember.Object.extend({
name: '',
nameLowerCase: function() {
return this.get('name').toLowerCase();
}.property('name')
});
IN .h
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
// This is an optional property from MKAnnotation
@property (nonatomic, copy) NSString *title;
IN .m
@synthesize coordinate, title;
rails g qunit:install
//= require application
//= require_tree .
//= require_self
document.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
document.write('<style>#ember-testing-container { position: absolute; background: white; bottom: 0; right: 0; width: 640px; height: 384px; overflow: auto; z-index: 9999; border: 1px solid #ccc; } #ember-testing { zoom: 50%; }</style>');
App.rootElement = '#ember-testing';
App.setupForTesting();
App.injectTestHelpers();
module("Ember.js Library", {
setup: function() {
Ember.run(App, App.advanceReadiness);
},
teardown: function() {
App.reset();
}
});
test("Check HTML is returned", function() {
test("Check retrieval of books", function() {
expect(6);
visit("/").then(function() {
ok(exists(".navBar"), "The navbar was rendered");
ok(exists("#searchButton"), "SearchButton was found");
});
visit("/").then(function() {
return click("#searchButton");