Skip to content

Instantly share code, notes, and snippets.

Avatar

David Ratajczak mockra

View GitHub Profile
View posts_test.js
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()
View places.js
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'
}
});
View comment_json
{
"comment": {
"id": 11,
"content": "this is my comment",
"post_id": 2
}
}
View comment.js
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')
});
View new.js
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});
View new.js
import Ember from 'ember';
export default Ember.Controller.extend({
searchText: null,
searchResults: [],
updateResults: function() {
var self = this;
var searchText = self.get('searchText');
View new.hbs
<div class="form-group">
{{input type="text" value=searchText placeholder="Search..."}}
</div>
{{updateResults}}
{{#each searchResults}}
<li>{{this}}</li>
{{/each}}
View new.js
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,
View gravatar-image-test.js
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);