Skip to content

Instantly share code, notes, and snippets.

@JohnnyBushy
Last active July 12, 2021 10:44
Show Gist options
  • Select an option

  • Save JohnnyBushy/961e319a1800a66585658d08dd4d5ba0 to your computer and use it in GitHub Desktop.

Select an option

Save JohnnyBushy/961e319a1800a66585658d08dd4d5ba0 to your computer and use it in GitHub Desktop.

Revisions

  1. JohnnyBushy revised this gist Jul 12, 2021. No changes.
  2. JohnnyBushy revised this gist Jul 10, 2021. 5 changed files with 35 additions and 3 deletions.
    2 changes: 1 addition & 1 deletion routes.application\.js
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,6 @@ export default class extends Route {
    @service store;

    model() {
    return this.store.createRecord('post', {content: 'Some content here'});
    return this.store.createRecord('post', {content: 'Some post content here'});
    }
    };
    2 changes: 1 addition & 1 deletion templates.components.my-component\.hbs
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    <p>{{post.content}}</p>
    <p>{{@post.content}}</p>
    16 changes: 16 additions & 0 deletions tests.acceptance.my-acceptance-test\.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    import { module, test } from 'qunit';
    import { visit, currentURL } from '@ember/test-helpers';
    import { setupApplicationTest } from 'ember-qunit';

    module('TODO: put something here', function(hooks) {
    setupApplicationTest(hooks);

    test('visiting /', async function(assert) {
    await visit('/');

    assert.equal(currentURL(), '/');

    // After the test is complete, there is an error thrown in the console
    // Attempted to handle event `willCommit` on <post:null> while in state root.empty.
    });
    });
    16 changes: 16 additions & 0 deletions tests.test-helper\.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    import Application from '../app';
    import config from '../config/environment';
    import { setApplication } from '@ember/test-helpers';
    import { assign } from '@ember/polyfills';
    import { start } from 'ember-qunit';

    let attributes = {
    rootElement: '#test-root',
    autoboot: false
    };
    attributes = assign(attributes, config.APP);

    let application = Application.create(attributes);
    setApplication(application);

    start();
    2 changes: 1 addition & 1 deletion twiddle\.json
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    },
    "options": {
    "use_pods": false,
    "enable-testing": false
    "enable-testing": true
    },
    "dependencies": {
    "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
  3. JohnnyBushy created this gist Jul 10, 2021.
    7 changes: 7 additions & 0 deletions components.my-component\.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    import Component from '@glimmer/component';

    export default class extends Component {
    willDestroy() {
    this.args.post.save();
    }
    }
    5 changes: 5 additions & 0 deletions controllers.application\.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    import Controller from '@ember/controller';

    export default class ApplicationController extends Controller {
    appName = 'Ember Twiddle';
    }
    6 changes: 6 additions & 0 deletions models.post\.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    import Model from 'ember-data/model';
    import attr from 'ember-data/attr';

    export default class extends Model {
    @attr('string') content;
    }
    10 changes: 10 additions & 0 deletions routes.application\.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    import Route from '@ember/routing/route';
    import { inject as service } from '@ember/service';

    export default class extends Route {
    @service store;

    model() {
    return this.store.createRecord('post', {content: 'Some content here'});
    }
    };
    1 change: 1 addition & 0 deletions templates.application\.hbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    <MyComponent @post={{@model}} />
    1 change: 1 addition & 0 deletions templates.components.my-component\.hbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    <p>{{post.content}}</p>
    23 changes: 23 additions & 0 deletions twiddle\.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    {
    "version": "0.17.1",
    "EmberENV": {
    "FEATURES": {},
    "_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
    "_APPLICATION_TEMPLATE_WRAPPER": true,
    "_JQUERY_INTEGRATION": true
    },
    "options": {
    "use_pods": false,
    "enable-testing": false
    },
    "dependencies": {
    "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
    "ember": "3.18.1",
    "ember-template-compiler": "3.18.1",
    "ember-testing": "3.18.1"
    },
    "addons": {
    "@glimmer/component": "1.0.0",
    "ember-data": "3.18.0"
    }
    }