Skip to content

Instantly share code, notes, and snippets.

View mockra's full-sized avatar

David Ratajczak mockra

View GitHub Profile
var request = require('supertest')
var Post = require('../../models/post')
describe('Posts Controller', function() {
describe('index', function() {
it('retrieves posts', function(done) {
new Post({
title: 'Test Post',
content: 'Test Content'
}).save()
function googlePlacesInitialize() {
var inputs;
inputs = $('input[data-google-places]');
return $.each(inputs, function() {
return new google.maps.places.Autocomplete(this, {
types: ['geocode'],
componentRestrictions: {
country: 'us'
}
});
{
"comment": {
"id": 11,
"content": "this is my comment",
"post_id": 2
}
}
import Ember from 'ember';
export default Ember.ObjectController.extend({
actions: {
create: function(post) {
var self = this;
var comment = this.store.createRecord('comment', {
post: post,
content: this.get('content')
});
import Ember from 'ember';
export default Ember.Controller.extend({
searchText: null,
searchResults: function() {
var searchText = this.get('searchText');
if (!searchText) { return; }
return this.store.find('post', {name: searchText});
import Ember from 'ember';
export default Ember.Controller.extend({
searchText: null,
searchResults: [],
updateResults: function() {
var self = this;
var searchText = self.get('searchText');
<div class="form-group">
{{input type="text" value=searchText placeholder="Search..."}}
</div>
{{updateResults}}
{{#each searchResults}}
<li>{{this}}</li>
{{/each}}
{{ errors.email }}
@mockra
mockra / new.js
Created September 16, 2014 00:45
import Ember from 'ember';
export default Ember.Controller.extend(Ember.Validations.Mixin, {
errors: [],
validations: {
email: {
presence: true,
format: {
with: /^[\w+\-.]+@[a-z\d\-.]+\.[a-z]+$/i,
import { test, moduleForComponent } from 'ember-qunit';
moduleForComponent('gravatar-image', 'GravatarImageComponent', {
});
test('it renders with size and e-mail', function() {
var component = this.subject();
Ember.run(function(){
component.set('size', 400);